From 553211119bbe57c177c233f26000dda7fa00b54a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Jan 2015 08:41:04 -0800 Subject: [PATCH] Update to rust master --- Cargo.lock | 117 +++++++++++----------- src/bin/bench.rs | 4 +- src/bin/build.rs | 4 +- src/bin/cargo.rs | 66 ++++++------ src/bin/clean.rs | 2 +- src/bin/config_for_key.rs | 2 +- src/bin/config_list.rs | 2 +- src/bin/doc.rs | 2 +- src/bin/generate_lockfile.rs | 2 +- src/bin/git_checkout.rs | 2 +- src/bin/login.rs | 2 +- src/bin/new.rs | 6 +- src/bin/run.rs | 4 +- src/bin/test.rs | 4 +- src/bin/update.rs | 2 +- src/bin/version.rs | 2 +- src/cargo/core/manifest.rs | 46 +++------ src/cargo/core/package.rs | 18 ++-- src/cargo/core/package_id.rs | 26 ++--- src/cargo/core/package_id_spec.rs | 4 +- src/cargo/core/registry.rs | 16 ++- src/cargo/core/resolver/encode.rs | 18 ++-- src/cargo/core/resolver/mod.rs | 32 +++--- src/cargo/core/shell.rs | 45 +++++---- src/cargo/core/source.rs | 30 +++--- src/cargo/lib.rs | 60 +++++------ src/cargo/ops/cargo_compile.rs | 6 +- src/cargo/ops/cargo_new.rs | 4 +- src/cargo/ops/cargo_read_manifest.rs | 15 ++- src/cargo/ops/cargo_rustc/compilation.rs | 13 ++- src/cargo/ops/cargo_rustc/context.rs | 9 +- src/cargo/ops/cargo_rustc/custom_build.rs | 41 ++++---- src/cargo/ops/cargo_rustc/engine.rs | 37 +++---- src/cargo/ops/cargo_rustc/fingerprint.rs | 14 +-- src/cargo/ops/cargo_rustc/job.rs | 2 +- src/cargo/ops/cargo_rustc/job_queue.rs | 22 ++-- src/cargo/ops/cargo_rustc/mod.rs | 28 +++--- src/cargo/ops/registry.rs | 8 +- src/cargo/sources/git/source.rs | 16 +-- src/cargo/sources/git/utils.rs | 30 +++--- src/cargo/sources/path.rs | 6 +- src/cargo/util/config.rs | 34 ++++--- src/cargo/util/dependency_queue.rs | 16 +-- src/cargo/util/errors.rs | 69 ++++++++----- src/cargo/util/graph.rs | 18 ++-- src/cargo/util/hex.rs | 10 +- src/cargo/util/lev_distance.rs | 4 +- src/cargo/util/paths.rs | 2 +- src/cargo/util/process_builder.rs | 51 +++++----- src/cargo/util/profile.rs | 8 +- src/cargo/util/sha256.rs | 2 +- src/cargo/util/toml.rs | 53 +++++----- src/registry/lib.rs | 12 +-- src/rustversion.txt | 2 +- tests/resolve.rs | 6 +- tests/support/mod.rs | 25 +++-- tests/support/paths.rs | 6 +- tests/support/registry.rs | 4 +- tests/test_cargo_bench.rs | 5 +- tests/test_cargo_build_auth.rs | 6 +- tests/test_cargo_compile.rs | 4 +- tests/test_cargo_compile_custom_build.rs | 1 + tests/test_cargo_compile_git_deps.rs | 11 +- tests/test_cargo_compile_plugins.rs | 13 +-- tests/test_cargo_cross_compile.rs | 33 ++---- tests/test_cargo_package.rs | 2 +- tests/test_cargo_publish.rs | 2 +- tests/test_cargo_test.rs | 6 +- tests/test_shell.rs | 6 +- tests/tests.rs | 5 +- 70 files changed, 600 insertions(+), 585 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c761cc25f..43732bc76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,30 +2,30 @@ name = "cargo" version = "0.1.0" dependencies = [ - "curl 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "docopt 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "glob 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "docopt 0.6.30 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)", - "log 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "registry 0.1.0", - "rustc-serialize 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl" -version = "0.1.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -34,22 +34,22 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libz-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "docopt" -version = "0.6.23" +version = "0.6.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "flate2" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "miniz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -57,37 +57,36 @@ dependencies = [ [[package]] name = "gcc" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "git2" -version = "0.1.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libgit2-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "glob" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hamcrest" version = "0.1.0" -source = "git+https://github.com/carllerche/hamcrest-rust.git#4ae58daf0b3a853ffd3109e63f94d43e8e623769" +source = "git+https://github.com/carllerche/hamcrest-rust.git#445dc78024c7d912d2e52dcd3ef3dfe2c8dbab47" [[package]] name = "libgit2-sys" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libssh2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -100,12 +99,12 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libz-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -113,37 +112,42 @@ name = "libz-sys" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pkg-config 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "matches" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "miniz-sys" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl-sys" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libressl-pnacl-sys 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pkg-config" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -153,61 +157,62 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "registry" version = "0.1.0" dependencies = [ - "curl 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-serialize" -version = "0.2.4" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "semver" -version = "0.1.9" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tar" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "term" -version = "0.1.2" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "time" -version = "0.1.9" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "toml" -version = "0.1.8" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "url" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 560df512c..56df9e294 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -9,7 +9,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd}; struct Options { flag_no_run: bool, flag_package: Option, - flag_jobs: Option, + flag_jobs: Option, flag_features: Vec, flag_bench: Option, flag_no_default_features: bool, @@ -76,7 +76,7 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult None => Ok(None), Some(err) => { Err(match err.exit { - Some(ExitStatus(i)) => CliError::new("", i as uint), + Some(ExitStatus(i)) => CliError::new("", i as u32), _ => CliError::from_boxed(box Human(err), 101) }) } diff --git a/src/bin/build.rs b/src/bin/build.rs index c23c323b0..61e92d611 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -9,7 +9,7 @@ use cargo::util::{CliResult, CliError}; #[derive(RustcDecodable)] struct Options { flag_package: Option, - flag_jobs: Option, + flag_jobs: Option, flag_features: Vec, flag_no_default_features: bool, flag_target: Option, @@ -44,7 +44,7 @@ current package is built. For more information on SPEC and its format, see the "; pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult> { - debug!("executing; cmd=cargo-build; args={}", os::args()); + debug!("executing; cmd=cargo-build; args={:?}", os::args()); shell.set_verbose(options.flag_verbose); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 149be5123..4d922090b 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -1,8 +1,8 @@ -#![feature(phase, macro_rules, old_orphan_check)] +#![allow(unstable)] extern crate "rustc-serialize" as rustc_serialize; -#[phase(plugin, link)] extern crate log; -#[phase(plugin, link)] extern crate cargo; +extern crate cargo; +#[macro_use] extern crate log; use std::collections::BTreeSet; use std::os; @@ -52,32 +52,32 @@ fn main() { execute_main_without_stdin(execute, true, USAGE) } -macro_rules! each_subcommand{ ($macro:ident) => ({ - $macro!(bench); - $macro!(build); - $macro!(clean); - $macro!(config_for_key); - $macro!(config_list); - $macro!(doc); - $macro!(fetch); - $macro!(generate_lockfile); - $macro!(git_checkout); - $macro!(help); - $macro!(locate_project); - $macro!(login); - $macro!(new); - $macro!(owner); - $macro!(package); - $macro!(pkgid); - $macro!(publish); - $macro!(read_manifest); - $macro!(run); - $macro!(search); - $macro!(test); - $macro!(update); - $macro!(verify_project); - $macro!(version); - $macro!(yank); +macro_rules! each_subcommand{ ($mac:ident) => ({ + $mac!(bench); + $mac!(build); + $mac!(clean); + $mac!(config_for_key); + $mac!(config_list); + $mac!(doc); + $mac!(fetch); + $mac!(generate_lockfile); + $mac!(git_checkout); + $mac!(help); + $mac!(locate_project); + $mac!(login); + $mac!(new); + $mac!(owner); + $mac!(package); + $mac!(pkgid); + $mac!(publish); + $mac!(read_manifest); + $mac!(run); + $mac!(search); + $mac!(test); + $mac!(update); + $mac!(verify_project); + $mac!(version); + $mac!(yank); }) } /** @@ -86,7 +86,7 @@ macro_rules! each_subcommand{ ($macro:ident) => ({ on this top-level information. */ fn execute(flags: Flags, shell: &mut MultiShell) -> CliResult> { - debug!("executing; cmd=cargo; args={}", os::args()); + debug!("executing; cmd=cargo; args={:?}", os::args()); shell.set_verbose(flags.flag_verbose); if flags.flag_list { @@ -139,7 +139,7 @@ fn find_closest(cmd: &str) -> Option { // allows us to only make suggestions that have an edit distance of // 3 or less .map(|c| (lev_distance(c.as_slice(), cmd), c)) - .filter(|&(d, _): &(uint, &String)| d < 4u) + .filter(|&(d, _): &(usize, &String)| d < 4) .min_by(|&(d, _)| d) { Some((_, c)) => { Some(c.to_string()) @@ -169,11 +169,11 @@ fn execute_subcommand(cmd: &str, args: &[String], shell: &mut MultiShell) { match status { Ok(ExitStatus(0)) => (), Ok(ExitStatus(i)) => { - handle_error(CliError::new("", i as uint), shell) + handle_error(CliError::new("", i as u32), shell) } Ok(ExitSignal(i)) => { let msg = format!("subcommand failed with signal: {}", i); - handle_error(CliError::new(msg, i as uint), shell) + handle_error(CliError::new(msg, i as u32), shell) } Err(io::IoError{kind, ..}) if kind == io::FileNotFound => handle_error(CliError::new("No such subcommand", 127), shell), diff --git a/src/bin/clean.rs b/src/bin/clean.rs index d5046d356..f5550c6cb 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -34,7 +34,7 @@ and its format, see the `cargo help pkgid` command. pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult> { shell.set_verbose(options.flag_verbose); - debug!("executing; cmd=cargo-clean; args={}", os::args()); + debug!("executing; cmd=cargo-clean; args={:?}", os::args()); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); let mut opts = ops::CleanOptions { diff --git a/src/bin/config_for_key.rs b/src/bin/config_for_key.rs index 1602ea121..4b106592a 100644 --- a/src/bin/config_for_key.rs +++ b/src/bin/config_for_key.rs @@ -33,7 +33,7 @@ pub fn execute(args: ConfigForKeyFlags, })); if args.flag_human { - println!("{}", value); + println!("{:?}", value); Ok(None) } else { let mut map = HashMap::new(); diff --git a/src/bin/config_list.rs b/src/bin/config_list.rs index 0fdf7e670..e267dbcd5 100644 --- a/src/bin/config_list.rs +++ b/src/bin/config_list.rs @@ -32,7 +32,7 @@ pub fn execute(args: ConfigListFlags, if args.flag_human { for (key, value) in configs.iter() { - println!("{} = {}", key, value); + println!("{} = {:?}", key, value); } Ok(None) } else { diff --git a/src/bin/doc.rs b/src/bin/doc.rs index daf8e3122..11f9823a8 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -6,7 +6,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { flag_features: Vec, - flag_jobs: Option, + flag_jobs: Option, flag_manifest_path: Option, flag_no_default_features: bool, flag_no_deps: bool, diff --git a/src/bin/generate_lockfile.rs b/src/bin/generate_lockfile.rs index e1fe72e3f..c2e50ddb4 100644 --- a/src/bin/generate_lockfile.rs +++ b/src/bin/generate_lockfile.rs @@ -24,7 +24,7 @@ Options: "; pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult> { - debug!("executing; cmd=cargo-generate-lockfile; args={}", os::args()); + debug!("executing; cmd=cargo-generate-lockfile; args={:?}", os::args()); shell.set_verbose(options.flag_verbose); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); diff --git a/src/bin/git_checkout.rs b/src/bin/git_checkout.rs index 1a19a3423..3e825ec3c 100644 --- a/src/bin/git_checkout.rs +++ b/src/bin/git_checkout.rs @@ -39,7 +39,7 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult let mut source = GitSource::new(&source_id, &mut config); try!(source.update().map_err(|e| { - CliError::new(format!("Couldn't update {}: {}", source, e), 1) + CliError::new(format!("Couldn't update {:?}: {:?}", source, e), 1) })); Ok(None) diff --git a/src/bin/login.rs b/src/bin/login.rs index 9b00c6508..6a164d4fe 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -30,7 +30,7 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult let token = match options.arg_token.clone() { Some(token) => token, None => { - let err = (|| { + let err = (|:| { let config = try!(Config::new(shell, None, None)); let src = try!(SourceId::for_central()); let mut src = RegistrySource::new(&src, &config); diff --git a/src/bin/new.rs b/src/bin/new.rs index 8677d2791..c68ec83de 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -23,15 +23,15 @@ Usage: Options: -h, --help Print this message --vcs Initialize a new repository for the given version - control system (git or hg) or do not initialize any version - control at all (none) overriding a global configuration. + control system (git or hg) or do not initialize any version + control at all (none) overriding a global configuration. --travis Create a .travis.yml file --bin Use a binary instead of a library template -v, --verbose Use verbose output "; pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult> { - debug!("executing; cmd=cargo-new; args={}", os::args()); + debug!("executing; cmd=cargo-new; args={:?}", os::args()); shell.set_verbose(options.flag_verbose); let Options { flag_travis, flag_bin, arg_path, flag_vcs, .. } = options; diff --git a/src/bin/run.rs b/src/bin/run.rs index 5124504f1..42456d1a9 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -10,7 +10,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd}; struct Options { flag_bin: Option, flag_example: Option, - flag_jobs: Option, + flag_jobs: Option, flag_features: Vec, flag_no_default_features: bool, flag_target: Option, @@ -88,7 +88,7 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult None => Ok(None), Some(err) => { Err(match err.exit { - Some(ExitStatus(i)) => CliError::from_boxed(box err, i as uint), + Some(ExitStatus(i)) => CliError::from_boxed(box err, i as u32), _ => CliError::from_boxed(box err, 101), }) } diff --git a/src/bin/test.rs b/src/bin/test.rs index b22b01e00..48a7db6c7 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -9,7 +9,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd}; struct Options { arg_args: Vec, flag_features: Vec, - flag_jobs: Option, + flag_jobs: Option, flag_manifest_path: Option, flag_test: Option, flag_no_default_features: bool, @@ -78,7 +78,7 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult None => Ok(None), Some(err) => { Err(match err.exit { - Some(ExitStatus(i)) => CliError::new("", i as uint), + Some(ExitStatus(i)) => CliError::new("", i as u32), _ => CliError::from_boxed(box Human(err), 101) }) } diff --git a/src/bin/update.rs b/src/bin/update.rs index 1e3dec520..005ea53fb 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -52,7 +52,7 @@ For more information about package id specifications, see `cargo help pkgid`. "; pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult> { - debug!("executing; cmd=cargo-update; args={}", os::args()); + debug!("executing; cmd=cargo-update; args={:?}", os::args()); shell.set_verbose(options.flag_verbose); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); diff --git a/src/bin/version.rs b/src/bin/version.rs index 1f9212e57..ab212987e 100644 --- a/src/bin/version.rs +++ b/src/bin/version.rs @@ -17,7 +17,7 @@ Options: "; pub fn execute(_: Options, _: &mut MultiShell) -> CliResult> { - debug!("executing; cmd=cargo-version; args={}", os::args()); + debug!("executing; cmd=cargo-version; args={:?}", os::args()); println!("{}", cargo::version()); diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index a8e3d4370..836919de5 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -1,5 +1,4 @@ use std::hash; -use std::fmt::{self, Show, Formatter}; use semver::Version; use rustc_serialize::{Encoder,Encodable}; @@ -10,7 +9,7 @@ use core::dependency::SerializedDependency; use util::{CargoResult, human}; /// Contains all the informations about a package, as loaded from a Cargo.toml. -#[derive(PartialEq,Clone)] +#[derive(PartialEq,Clone, Show)] pub struct Manifest { summary: Summary, targets: Vec, @@ -24,15 +23,6 @@ pub struct Manifest { metadata: ManifestMetadata, } -impl Show for Manifest { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "Manifest({}, targets={}, target_dir={}, \ - build={})", - self.summary, self.targets, self.target_dir.display(), - self.build) - } -} - /// General metadata about a package which is just blindly uploaded to the /// registry. /// @@ -41,7 +31,7 @@ impl Show for Manifest { /// validated by cargo itself, but rather it is up to the registry when uploaded /// to validate these fields. Cargo will itself accept any valid TOML /// specification for these values. -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Show)] pub struct ManifestMetadata { pub authors: Vec, pub keywords: Vec, @@ -65,8 +55,8 @@ pub struct SerializedManifest { build: Option>, // TODO: deprecated, remove } -impl> Encodable for Manifest { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for Manifest { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { SerializedManifest { name: self.summary.get_name().to_string(), version: self.summary.get_version().to_string(), @@ -127,9 +117,9 @@ pub enum TargetKind { #[derive(RustcEncodable, RustcDecodable, Clone, PartialEq, Show)] pub struct Profile { env: String, // compile, test, dev, bench, etc. - opt_level: uint, + opt_level: u32, lto: bool, - codegen_units: Option, // None = use rustc default + codegen_units: Option, // None = use rustc default debug: bool, rpath: bool, test: bool, @@ -243,7 +233,7 @@ impl Profile { self.for_host } - pub fn get_opt_level(&self) -> uint { + pub fn get_opt_level(&self) -> u32 { self.opt_level } @@ -251,7 +241,7 @@ impl Profile { self.lto } - pub fn get_codegen_units(&self) -> Option { + pub fn get_codegen_units(&self) -> Option { self.codegen_units } @@ -271,7 +261,7 @@ impl Profile { self.dest.as_ref().map(|d| d.as_slice()) } - pub fn opt_level(mut self, level: uint) -> Profile { + pub fn opt_level(mut self, level: u32) -> Profile { self.opt_level = level; self } @@ -281,7 +271,7 @@ impl Profile { self } - pub fn codegen_units(mut self, units: Option) -> Profile { + pub fn codegen_units(mut self, units: Option) -> Profile { self.codegen_units = units; self } @@ -329,7 +319,7 @@ impl Profile { } } -impl hash::Hash for Profile { +impl hash::Hash for Profile { fn hash(&self, into: &mut H) { // Be sure to match all fields explicitly, but ignore those not relevant // to the actual hash of a profile. @@ -359,7 +349,7 @@ impl hash::Hash for Profile { } /// Informations about a binary, a library, an example, etc. that is part of the package. -#[derive(Clone, Hash, PartialEq)] +#[derive(Clone, Hash, PartialEq, Show)] pub struct Target { kind: TargetKind, name: String, @@ -377,8 +367,8 @@ pub struct SerializedTarget { metadata: Option } -impl> Encodable for Target { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for Target { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { let kind = match self.kind { TargetKind::Lib(ref kinds) => kinds.iter().map(|k| k.crate_type()).collect(), TargetKind::Bin => vec!("bin"), @@ -395,14 +385,6 @@ impl> Encodable for Target { } } -impl Show for Target { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "{}(name={}, path={}, profile={})", self.kind, self.name, - self.src_path.display(), self.profile) - } -} - - impl Manifest { pub fn new(summary: Summary, targets: Vec, target_dir: Path, doc_dir: Path, diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 794ccd3d3..75d85a848 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Show, Formatter}; +use std::fmt::{self, Formatter}; use std::hash; use std::slice; use semver::Version; @@ -20,7 +20,7 @@ use core::source::{SourceId, Source}; /// /// A package is a `Cargo.toml` file, plus all the files that are part of it. // TODO: Is manifest_path a relic? -#[derive(Clone)] +#[derive(Clone, Show)] pub struct Package { // The package's manifest manifest: Manifest, @@ -39,8 +39,8 @@ struct SerializedPackage { manifest_path: String, } -impl> Encodable for Package { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for Package { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { let manifest = self.get_manifest(); let summary = manifest.get_summary(); let package_id = summary.get_package_id(); @@ -117,8 +117,8 @@ impl Package { } } -impl Show for Package { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { +impl fmt::String for Package { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.get_summary().get_package_id()) } } @@ -131,8 +131,8 @@ impl PartialEq for Package { impl Eq for Package {} -impl hash::Hash for Package { - fn hash(&self, into: &mut hash::sip::SipState) { +impl hash::Hash for Package { + fn hash(&self, into: &mut H) { self.get_package_id().hash(into) } } @@ -149,7 +149,7 @@ impl PackageSet { PackageSet { packages: packages.to_vec() } } - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.packages.len() } diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs index a3db63d48..6a5b2b28e 100644 --- a/src/cargo/core/package_id.rs +++ b/src/cargo/core/package_id.rs @@ -1,7 +1,7 @@ use std::cmp::Ordering; use std::error::{Error, FromError}; -use std::fmt::{self, Show, Formatter}; -use std::hash::Hash; +use std::fmt::{self, Formatter}; +use std::hash::{Hash, SipHasher}; use std::hash; use std::sync::Arc; @@ -13,20 +13,20 @@ use util::{CargoResult, CargoError, short_hash, ToSemver}; use core::source::SourceId; /// Identifier for a specific version of a package in a specific source. -#[derive(Clone)] +#[derive(Clone, Show)] pub struct PackageId { inner: Arc, } -#[derive(PartialEq, PartialOrd, Eq, Ord)] +#[derive(PartialEq, PartialOrd, Eq, Ord, Show)] struct PackageIdInner { name: String, version: semver::Version, source_id: SourceId, } -impl> Encodable for PackageId { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for PackageId { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { let source = self.inner.source_id.to_url(); let encoded = format!("{} {} ({})", self.inner.name, self.inner.version, source); @@ -34,8 +34,8 @@ impl> Encodable for PackageId { } } -impl> Decodable for PackageId { - fn decode(d: &mut D) -> Result { +impl Decodable for PackageId { + fn decode(d: &mut D) -> Result { let string: String = try!(Decodable::decode(d)); let regex = Regex::new(r"^([^ ]+) ([^ ]+) \(([^\)]+)\)$").unwrap(); let captures = regex.captures(string.as_slice()).expect("invalid serialized PackageId"); @@ -56,7 +56,7 @@ impl> Decodable for PackageId { } } -impl Hash for PackageId { +impl Hash for PackageId { fn hash(&self, state: &mut S) { self.inner.name.hash(state); self.inner.version.to_string().hash(state); @@ -106,10 +106,10 @@ impl CargoError for PackageIdError { } impl FromError for Box { - fn from_error(t: PackageIdError) -> Box { box t } + fn from_error(t: PackageIdError) -> Box { Box::new(t) } } -#[derive(PartialEq, Hash, Clone, RustcEncodable)] +#[derive(PartialEq, Hash, Clone, RustcEncodable, Show)] pub struct Metadata { pub metadata: String, pub extra_filename: String @@ -161,14 +161,14 @@ impl PackageId { } impl Metadata { - pub fn mix(&mut self, t: &T) { + pub fn mix>(&mut self, t: &T) { let new_metadata = short_hash(&(self.metadata.as_slice(), t)); self.extra_filename = format!("-{}", new_metadata); self.metadata = new_metadata; } } -impl Show for PackageId { +impl fmt::String for PackageId { fn fmt(&self, f: &mut Formatter) -> fmt::Result { try!(write!(f, "{} v{}", self.inner.name, self.inner.version)); diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index dce16d30c..d688b6e45 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -5,7 +5,7 @@ use url::{self, Url, UrlParser}; use core::PackageId; use util::{CargoResult, ToUrl, human, ToSemver, ChainError}; -#[derive(Clone, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq, Show)] pub struct PackageIdSpec { name: String, version: Option, @@ -129,7 +129,7 @@ fn url(s: &str) -> url::ParseResult { } -impl fmt::Show for PackageIdSpec { +impl fmt::String for PackageIdSpec { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut printed_name = false; match self.url { diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index dfa9aa116..65f122943 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -15,8 +15,8 @@ pub trait Registry { impl Registry for Vec { fn query(&mut self, dep: &Dependency) -> CargoResult> { - debug!("querying for {}, summaries={}", dep, - self.iter().map(|s| s.get_package_id().to_string()).collect::>()); + debug!("querying for {:?}, summaries={:?}", dep, + self.iter().map(|s| s.get_package_id()).collect::>()); Ok(self.iter().filter(|summary| dep.matches(*summary)) .map(|summary| summary.clone()).collect()) @@ -83,7 +83,7 @@ impl<'a> PackageRegistry<'a> { } pub fn get(&mut self, package_ids: &[PackageId]) -> CargoResult> { - log!(5, "getting packags; sources={}; ids={}", self.sources.len(), + log!(5, "getting packags; sources={}; ids={:?}", self.sources.len(), package_ids); // TODO: Only call source with package ID if the package came from the @@ -99,7 +99,7 @@ impl<'a> PackageRegistry<'a> { // TODO: Return earlier if fail assert!(package_ids.len() == ret.len(), - "could not get packages from registry; ids={}; ret={}", + "could not get packages from registry; ids={:?}; ret={:?}", package_ids, ret); Ok(ret) @@ -152,13 +152,11 @@ impl<'a> PackageRegistry<'a> { } pub fn register_lock(&mut self, id: PackageId, deps: Vec) { - let source = id.get_source_id().clone(); - let sub_map = match self.locked.entry(&source) { + let sub_map = match self.locked.entry(id.get_source_id().clone()) { Occupied(e) => e.into_mut(), Vacant(e) => e.insert(HashMap::new()), }; - let name = id.get_name().to_string(); - let sub_vec = match sub_map.entry(&name) { + let sub_vec = match sub_map.entry(id.get_name().to_string()) { Occupied(e) => e.into_mut(), Vacant(e) => e.insert(Vec::new()), }; @@ -347,7 +345,7 @@ pub mod test { impl Registry for RegistryBuilder { fn query(&mut self, dep: &Dependency) -> CargoResult> { - debug!("querying; dep={}", dep); + debug!("querying; dep={:?}", dep); let overrides = self.query_overrides(dep); diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index baae96b95..ba9923efa 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -26,7 +26,8 @@ impl EncodableResolve { let packages = self.package.as_ref().unwrap_or(&packages); { - let register_pkg = |pkg: &EncodableDependency| -> CargoResult<()> { + let mut register_pkg = |&mut: pkg: &EncodableDependency| + -> CargoResult<()> { let pkgid = try!(pkg.to_package_id(default)); let precise = pkgid.get_source_id().get_precise() .map(|s| s.to_string()); @@ -43,7 +44,8 @@ impl EncodableResolve { } { - let add_dependencies = |pkg: &EncodableDependency| -> CargoResult<()> { + let mut add_dependencies = |&mut: pkg: &EncodableDependency| + -> CargoResult<()> { let package_id = try!(pkg.to_package_id(default)); let deps = match pkg.dependencies { @@ -100,8 +102,8 @@ pub struct EncodablePackageId { source: Option } -impl> Encodable for EncodablePackageId { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for EncodablePackageId { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { let mut out = format!("{} {}", self.name, self.version); if let Some(ref s) = self.source { out.push_str(format!(" ({})", s.to_url()).as_slice()); @@ -110,8 +112,8 @@ impl> Encodable for EncodablePackageId { } } -impl> Decodable for EncodablePackageId { - fn decode(d: &mut D) -> Result { +impl Decodable for EncodablePackageId { + fn decode(d: &mut D) -> Result { let string: String = try!(Decodable::decode(d)); let regex = Regex::new(r"^([^ ]+) ([^ ]+)(?: \(([^\)]+)\))?$").unwrap(); let captures = regex.captures(string.as_slice()) @@ -141,8 +143,8 @@ impl EncodablePackageId { } } -impl> Encodable for Resolve { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for Resolve { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { let mut ids: Vec<&PackageId> = self.graph.iter().collect(); ids.sort(); diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 09e2fca38..066dac76f 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -92,9 +92,9 @@ impl Resolve { spec: &PackageIdSpec) { let mut version_cnt = HashMap::new(); for id in ids.iter() { - match version_cnt.entry(&id.get_version()) { - Vacant(e) => { e.insert(1u); } - Occupied(e) => *e.into_mut() += 1u, + match version_cnt.entry(id.get_version()) { + Vacant(e) => { e.insert(1); } + Occupied(e) => *e.into_mut() += 1, } } for id in ids.iter() { @@ -131,14 +131,14 @@ struct Context { /// Builds the list of all packages required to build the first argument. pub fn resolve(summary: &Summary, method: Method, registry: &mut R) -> CargoResult { - log!(5, "resolve; summary={}", summary); + log!(5, "resolve; summary={:?}", summary); let mut cx = Context { resolve: Resolve::new(summary.get_package_id().clone()), activations: HashMap::new(), visited: Rc::new(RefCell::new(HashSet::new())), }; - let _p = profile::start(format!("resolving: {}", summary)); + let _p = profile::start(format!("resolving: {:?}", summary)); cx.activations.insert((summary.get_name().to_string(), summary.get_source_id().clone()), vec![Rc::new(summary.clone())]); @@ -193,7 +193,7 @@ fn activate_deps<'a, R: Registry>(cx: Context, parent: &Summary, platform: Option<&'a str>, deps: &'a [(&Dependency, Vec>, Vec)], - cur: uint) -> CargoResult> { + cur: usize) -> CargoResult> { if cur == deps.len() { return Ok(Ok(cx)) } let (dep, ref candidates, ref features) = deps[cur]; let method = Method::Required(false, features.as_slice(), @@ -240,7 +240,7 @@ fn activate_deps<'a, R: Registry>(cx: Context, let early_return = { my_cx.resolve.graph.link(parent.get_package_id().clone(), candidate.get_package_id().clone()); - let prev = match my_cx.activations.entry(&key) { + let prev = match my_cx.activations.entry(key.clone()) { Occupied(e) => e.into_mut(), Vacant(e) => e.insert(Vec::new()), }; @@ -284,7 +284,8 @@ fn activate_deps<'a, R: Registry>(cx: Context, Err(e) => { last_err = Some(e); } } } - log!(5, "{}[{}]>{} -- {}", parent.get_name(), cur, dep.get_name(), last_err); + log!(5, "{}[{}]>{} -- {:?}", parent.get_name(), cur, dep.get_name(), + last_err); // Oh well, we couldn't activate any of the candidates, so we just can't // activate this dependency at all @@ -315,9 +316,12 @@ fn activate_deps<'a, R: Registry>(cx: Context, v.get_version()).as_slice()); } - msg.push_str(format!("\n possible versions to select: {}", - candidates.iter().map(|v| v.get_version()) - .collect::>()).as_slice()); + msg.push_str(&format!("\n possible versions to select: {}", + candidates.iter() + .map(|v| v.get_version()) + .map(|v| v.to_string()) + .collect::>() + .connect(", "))[]); Err(human(msg)) } @@ -408,7 +412,7 @@ fn resolve_features<'a>(cx: &mut Context, parent: &'a Summary, // Record what list of features is active for this package. if used_features.len() > 0 { let pkgid = parent.get_package_id(); - match cx.resolve.features.entry(pkgid) { + match cx.resolve.features.entry(pkgid.clone()) { Occupied(entry) => entry.into_mut(), Vacant(entry) => entry.insert(HashSet::new()), }.extend(used_features.into_iter()); @@ -477,7 +481,7 @@ fn build_features(s: &Summary, method: Method) match parts.next() { Some(feat) => { let package = feat_or_package; - match deps.entry(package) { + match deps.entry(package.to_string()) { Occupied(e) => e.into_mut(), Vacant(e) => e.insert(Vec::new()), }.push(feat.to_string()); @@ -498,7 +502,7 @@ fn build_features(s: &Summary, method: Method) } } None => { - match deps.entry(feat) { + match deps.entry(feat.to_string()) { Occupied(..) => {} // already activated Vacant(e) => { e.insert(Vec::new()); } } diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 8d25db75e..2b9745540 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -1,8 +1,9 @@ -use term::{Terminal, TerminfoTerminal, color}; -use term::color::{Color, BLACK, RED, GREEN, YELLOW}; -use term::attr::{Attr, Bold}; +use std::fmt; use std::io::{IoResult, stderr}; -use std::fmt::Show; + +use term::Attr; +use term::color::{Color, BLACK, RED, GREEN, YELLOW}; +use term::{Terminal, TerminfoTerminal, color}; use self::AdequateTerminal::{NoColor, Colored}; @@ -29,8 +30,6 @@ pub struct MultiShell { verbose: bool } -pub type Callback<'a> = |&mut MultiShell|:'a -> IoResult<()>; - struct UghWhyIsThisNecessary { inner: Box, } @@ -52,16 +51,22 @@ impl MultiShell { self.out().say(message, color) } - pub fn status(&mut self, status: T, message: U) -> IoResult<()> { + pub fn status(&mut self, status: T, message: U) -> IoResult<()> + where T: fmt::String, U: fmt::String + { self.out().say_status(status, message, GREEN) } - pub fn verbose(&mut self, callback: Callback) -> IoResult<()> { + pub fn verbose(&mut self, mut callback: F) -> IoResult<()> + where F: FnMut(&mut MultiShell) -> IoResult<()> + { if self.verbose { return callback(self) } Ok(()) } - pub fn concise(&mut self, callback: Callback) -> IoResult<()> { + pub fn concise(&mut self, mut callback: F) -> IoResult<()> + where F: FnMut(&mut MultiShell) -> IoResult<()> + { if !self.verbose { return callback(self) } Ok(()) } @@ -83,8 +88,6 @@ impl MultiShell { } } -pub type ShellCallback<'a> = |&mut Shell|:'a -> IoResult<()>; - impl Shell { pub fn create(out: Box, config: ShellConfig) -> Shell { let out = UghWhyIsThisNecessary { inner: out }; @@ -94,19 +97,23 @@ impl Shell { terminal: Colored(t), config: config }).unwrap_or_else(|| { - Shell { terminal: NoColor(box stderr()), config: config } + Shell { terminal: NoColor(Box::new(stderr())), config: config } }) } else { Shell { terminal: NoColor(out.inner), config: config } } } - pub fn verbose(&mut self, callback: ShellCallback) -> IoResult<()> { + pub fn verbose(&mut self, mut callback: F) -> IoResult<()> + where F: FnMut(&mut Shell) -> IoResult<()> + { if self.config.verbose { return callback(self) } Ok(()) } - pub fn concise(&mut self, callback: ShellCallback) -> IoResult<()> { + pub fn concise(&mut self, mut callback: F) -> IoResult<()> + where F: FnMut(&mut Shell) -> IoResult<()> + { if !self.config.verbose { return callback(self) } Ok(()) } @@ -120,11 +127,13 @@ impl Shell { Ok(()) } - pub fn say_status(&mut self, status: T, message: U, - color: Color) -> IoResult<()> { + pub fn say_status(&mut self, status: T, message: U, color: Color) + -> IoResult<()> + where T: fmt::String, U: fmt::String + { try!(self.reset()); if color != BLACK { try!(self.fg(color)); } - if self.supports_attr(Bold) { try!(self.attr(Bold)); } + if self.supports_attr(Attr::Bold) { try!(self.attr(Attr::Bold)); } try!(self.write_str(format!("{:>12}", status).as_slice())); try!(self.reset()); try!(self.write_line(format!(" {}", message).as_slice())); @@ -155,7 +164,7 @@ impl Shell { fn reset(&mut self) -> IoResult<()> { match self.terminal { - Colored(ref mut c) => c.reset(), + Colored(ref mut c) => c.reset().map(|_| ()), NoColor(_) => Ok(()) } } diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index de7b3ea64..88ab4e1b0 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -1,6 +1,6 @@ use std::collections::hash_map::{HashMap, Values, IterMut}; use std::cmp::Ordering; -use std::fmt::{self, Show, Formatter}; +use std::fmt::{self, Formatter}; use std::hash; use std::mem; use std::sync::Arc; @@ -63,12 +63,12 @@ pub enum GitReference { type Error = Box; /// Unique identifier for a source of packages. -#[derive(Clone, Eq)] +#[derive(Clone, Eq, Show)] pub struct SourceId { inner: Arc, } -#[derive(Eq, Clone)] +#[derive(Eq, Clone, Show)] struct SourceIdInner { url: Url, kind: Kind, @@ -195,16 +195,16 @@ impl SourceId { pub fn load<'a>(&self, config: &'a Config) -> Box { log!(5, "loading SourceId; {}", self); match self.inner.kind { - Kind::Git(..) => box GitSource::new(self, config) as Box, + Kind::Git(..) => Box::new(GitSource::new(self, config)) as Box, Kind::Path => { let path = match self.inner.url.to_file_path() { Ok(p) => p, Err(()) => panic!("path sources cannot be remote"), }; - box PathSource::new(&path, self) as Box + Box::new(PathSource::new(&path, self)) as Box }, Kind::Registry => { - box RegistrySource::new(self, config) as Box + Box::new(RegistrySource::new(self, config)) as Box } } } @@ -256,8 +256,8 @@ impl Ord for SourceId { } } -impl> Encodable for SourceId { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for SourceId { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { if self.is_path() { s.emit_option_none() } else { @@ -266,17 +266,19 @@ impl> Encodable for SourceId { } } -impl> Decodable for SourceId { - fn decode(d: &mut D) -> Result { +impl Decodable for SourceId { + fn decode(d: &mut D) -> Result { let string: String = Decodable::decode(d).ok().expect("Invalid encoded SourceId"); Ok(SourceId::from_url(string)) } } -impl Show for SourceId { +impl fmt::String for SourceId { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match *self.inner { - SourceIdInner { kind: Kind::Path, ref url, .. } => url.fmt(f), + SourceIdInner { kind: Kind::Path, ref url, .. } => { + fmt::String::fmt(url, f) + } SourceIdInner { kind: Kind::Git(ref reference), ref url, ref precise, .. } => { try!(write!(f, "{}{}", url, url_ref(reference))); @@ -314,7 +316,7 @@ impl PartialEq for SourceIdInner { } } -impl hash::Hash for SourceId { +impl hash::Hash for SourceId { fn hash(&self, into: &mut S) { self.inner.kind.hash(into); match *self.inner { @@ -394,7 +396,7 @@ impl<'src> SourceMap<'src> { self.map.insert(id.clone(), source); } - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.map.len() } diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 799c9e7b0..7c07021eb 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -1,9 +1,5 @@ -#![crate_name="cargo"] -#![crate_type="rlib"] - -#![feature(macro_rules, phase, default_type_params, unboxed_closures)] -#![feature(slicing_syntax, old_orphan_check, associated_types)] #![deny(unused)] +#![allow(unstable)] #![cfg_attr(test, deny(warnings))] extern crate libc; @@ -11,7 +7,7 @@ extern crate "rustc-serialize" as rustc_serialize; extern crate regex; extern crate term; extern crate time; -#[phase(plugin, link)] extern crate log; +#[macro_use] extern crate log; extern crate curl; extern crate docopt; @@ -27,11 +23,10 @@ extern crate url; extern crate registry; use std::error::Error; -use std::fmt; use std::io::stdio::{stdout_raw, stderr_raw}; use std::io::{self, stdout, stderr}; use std::os; -use rustc_serialize::{Decoder, Encoder, Decodable, Encodable}; +use rustc_serialize::{Decodable, Encodable}; use rustc_serialize::json::{self, Json}; use docopt::Docopt; @@ -62,18 +57,15 @@ pub mod ops; pub mod sources; pub mod util; -pub trait RepresentsJSON : Decodable {} -impl> RepresentsJSON for T {} - pub fn execute_main( exec: fn(T, U, &mut MultiShell) -> CliResult>, options_first: bool, usage: &str) - where V: for<'a> Encodable, fmt::Error>, - T: Decodable, - U: RepresentsJSON + where V: Encodable, T: Decodable, U: Decodable { - process::(|rest, shell| call_main(exec, shell, usage, rest, options_first)); + process::(|rest, shell| { + call_main(exec, shell, usage, rest, options_first) + }); } pub fn call_main( @@ -82,9 +74,7 @@ pub fn call_main( usage: &str, args: &[String], options_first: bool) -> CliResult> - where V: for<'a> Encodable, fmt::Error>, - T: Decodable, - U: RepresentsJSON + where V: Encodable, T: Decodable, U: Decodable { let flags = try!(flags_from_args::(usage, args, options_first)); let json = try!(json_from_stdin::()); @@ -96,11 +86,11 @@ pub fn execute_main_without_stdin( exec: fn(T, &mut MultiShell) -> CliResult>, options_first: bool, usage: &str) - where V: for<'a> Encodable, fmt::Error>, - T: Decodable + where V: Encodable, T: Decodable { - process::(|rest, shell| call_main_without_stdin(exec, shell, usage, rest, - options_first)); + process::(|rest, shell| { + call_main_without_stdin(exec, shell, usage, rest, options_first) + }); } pub fn execute_main_with_args_and_without_stdin( @@ -108,8 +98,7 @@ pub fn execute_main_with_args_and_without_stdin( options_first: bool, usage: &str, args: &[String]) - where V: for<'a> Encodable, fmt::Error>, - T: Decodable + where V: Encodable, T: Decodable { let mut shell = shell(true); @@ -124,15 +113,15 @@ pub fn call_main_without_stdin( usage: &str, args: &[String], options_first: bool) -> CliResult> - where V: for<'a> Encodable, fmt::Error>, - T: Decodable + where V: Encodable, T: Decodable { let flags = try!(flags_from_args::(usage, args, options_first)); exec(flags, shell) } -fn process(callback: |&[String], &mut MultiShell| -> CliResult>) - where V: for<'a> Encodable, fmt::Error> +fn process(mut callback: F) + where F: FnMut(&[String], &mut MultiShell) -> CliResult>, + V: Encodable { let mut shell = shell(true); process_executed(callback(os::args().as_slice(), &mut shell), &mut shell) @@ -140,7 +129,7 @@ fn process(callback: |&[String], &mut MultiShell| -> CliResult>) pub fn process_executed(result: CliResult>, shell: &mut MultiShell) - where T: for<'a> Encodable, fmt::Error> + where T: Encodable { match result { Err(e) => handle_error(e, shell), @@ -154,13 +143,13 @@ pub fn process_executed(result: CliResult>, pub fn shell(verbose: bool) -> MultiShell { let tty = stderr_raw().isatty(); - let stderr = box stderr() as Box; + let stderr = Box::new(stderr()) as Box; let config = ShellConfig { color: true, verbose: verbose, tty: tty }; let err = Shell::create(stderr, config); let tty = stdout_raw().isatty(); - let stdout = box stdout() as Box; + let stdout = Box::new(stdout()) as Box; let config = ShellConfig { color: true, verbose: verbose, tty: tty }; let out = Shell::create(stdout, config); @@ -185,7 +174,7 @@ fn output(caption: Option, detail: Option, } pub fn handle_error(err: CliError, shell: &mut MultiShell) { - log!(4, "handle_error; err={}", err); + log!(4, "handle_error; err={:?}", err); let CliError { error, exit_code, unknown } = err; let verbose = shell.get_verbose(); @@ -217,7 +206,7 @@ pub fn handle_error(err: CliError, shell: &mut MultiShell) { } } - std::os::set_exit_status(exit_code as int); + std::os::set_exit_status(exit_code as isize); } fn handle_cause(mut err: &Error, shell: &mut MultiShell) { @@ -245,7 +234,8 @@ pub fn version() -> String { fn flags_from_args<'a, T>(usage: &str, args: &[String], options_first: bool) -> CliResult - where T: Decodable { + where T: Decodable +{ struct CargoDocoptError { err: docopt::Error } impl Error for CargoDocoptError { fn description(&self) -> &str { @@ -281,7 +271,7 @@ fn flags_from_args<'a, T>(usage: &str, args: &[String], }) } -fn json_from_stdin() -> CliResult { +fn json_from_stdin() -> CliResult { let mut reader = io::stdin(); let input = try!(reader.read_to_string().map_err(|_| { CliError::new("Standard in did not exist or was not UTF-8", 1) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 2c91141cd..4da2ad92b 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -40,7 +40,7 @@ pub struct CompileOptions<'a> { pub env: &'a str, pub shell: &'a mut MultiShell, /// Number of concurrent jobs to use. - pub jobs: Option, + pub jobs: Option, /// The target platform to compile for (example: `i686-unknown-linux-gnu`). pub target: Option<&'a str>, /// True if dev-dependencies must be compiled. @@ -123,7 +123,7 @@ pub fn compile_pkg(package: &Package, options: &mut CompileOptions) (packages, resolved_with_overrides, registry.move_sources()) }; - debug!("packages={}", packages); + debug!("packages={:?}", packages); let to_build = match spec { Some(spec) => { @@ -160,7 +160,7 @@ pub fn compile_pkg(package: &Package, options: &mut CompileOptions) fn source_ids_from_config(configs: &HashMap, cur_path: Path) -> CargoResult> { - debug!("loaded config; configs={}", configs); + debug!("loaded config; configs={:?}", configs); let config_paths = match configs.get("paths") { Some(cfg) => cfg, diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index a4b4eebba..811e9dd5f 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -19,8 +19,8 @@ pub struct NewOptions<'a> { pub path: &'a str, } -impl> Decodable for VersionControl { - fn decode(d: &mut D) -> Result { +impl Decodable for VersionControl { + fn decode(d: &mut D) -> Result { Ok(match try!(d.read_str()).as_slice() { "git" => VersionControl::Git, "hg" => VersionControl::Hg, diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 02ff5999b..432e6fd45 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -57,13 +57,20 @@ pub fn read_packages(path: &Path, if all_packages.is_empty() { Err(human(format!("Could not find Cargo.toml in `{}`", path.display()))) } else { - log!(5, "all packages: {}", all_packages); + log!(5, "all packages: {:?}", all_packages); Ok(all_packages.into_iter().collect()) } } -fn walk(path: &Path, - callback: |&Path| -> CargoResult) -> CargoResult<()> { +fn walk(path: &Path, mut callback: F) -> CargoResult<()> + where F: FnMut(&Path) -> CargoResult +{ + walk_inner(path, &mut callback) +} + +fn walk_inner(path: &Path, callback: &mut F) -> CargoResult<()> + where F: FnMut(&Path) -> CargoResult +{ if path.is_dir() { let continues = try!(callback(path)); if !continues { @@ -79,7 +86,7 @@ fn walk(path: &Path, Err(e) => return Err(FromError::from_error(e)), }; for dir in dirs.iter() { - try!(walk(dir, |x| callback(x))) + try!(walk_inner(dir, callback)); } } diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index c8313964f..5750924c2 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; -use std::c_str::ToCStr; use std::dynamic_lib::DynamicLibrary; +use std::ffi::CString; +use std::path::BytesContainer; use semver::Version; use core::{PackageId, Package}; @@ -68,15 +69,17 @@ impl Compilation { } /// See `process`. - pub fn target_process(&self, cmd: T, pkg: &Package) + pub fn target_process(&self, cmd: T, pkg: &Package) -> CargoResult { - self.process(CommandType::Target(cmd.to_c_str()), pkg) + let cmd = CString::from_slice(cmd.container_as_bytes()); + self.process(CommandType::Target(cmd), pkg) } /// See `process`. - pub fn host_process(&self, cmd: T, pkg: &Package) + pub fn host_process(&self, cmd: T, pkg: &Package) -> CargoResult { - self.process(CommandType::Host(cmd.to_c_str()), pkg) + let cmd = CString::from_slice(cmd.container_as_bytes()); + self.process(CommandType::Host(cmd), pkg) } /// Prepares a new process with an appropriate environment to run against diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 8ddf900d6..1b4843f90 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -77,7 +77,7 @@ impl<'a, 'b: 'a> Context<'a, 'b> { compilation: Compilation::new(root_pkg), build_state: Arc::new(BuildState::new(build_config.clone(), deps)), build_config: build_config, - exec_engine: Arc::new(box ProcessEngine as Box), + exec_engine: Arc::new(Box::new(ProcessEngine) as Box), }) } @@ -90,7 +90,7 @@ impl<'a, 'b: 'a> Context<'a, 'b> { .arg("--crate-name").arg("-") .arg("--crate-type").arg("dylib") .arg("--crate-type").arg("bin") - .arg("--print-file-name"); + .arg("--print=file-names"); let process = match target { Some(s) => process.arg("--target").arg(s), None => process, @@ -157,9 +157,8 @@ impl<'a, 'b: 'a> Context<'a, 'b> { fn build_requirements(&mut self, pkg: &'a Package, target: &'a Target, req: Platform) { - let req = if target.get_profile().is_for_host() {Platform::Plugin} else {req}; - match self.requirements.entry(&(pkg.get_package_id(), target.get_name())) { + match self.requirements.entry((pkg.get_package_id(), target.get_name())) { Occupied(mut entry) => match (*entry.get(), req) { (Platform::Plugin, Platform::Plugin) | (Platform::PluginAndTarget, Platform::Plugin) | @@ -367,7 +366,7 @@ impl Platform { } } - pub fn each_kind(self, f: |Kind|) { + pub fn each_kind(self, mut f: F) where F: FnMut(Kind) { match self { Platform::Target => f(Kind::Target), Platform::Plugin => f(Kind::Host), diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index f0da72f5f..87f8c5c6c 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -1,6 +1,5 @@ -use std::c_str::ToCStr; use std::collections::HashMap; -use std::fmt; +use std::ffi::CString; use std::io::fs::PathExtensions; use std::io::{fs, USER_RWX, File}; use std::str; @@ -17,7 +16,7 @@ use super::CommandType; use util::Freshness; /// Contains the parsed output of a custom build script. -#[derive(Clone)] +#[derive(Clone, Show)] pub struct BuildOutput { /// Paths to pass to rustc with the `-L` flag pub library_paths: Vec, @@ -52,20 +51,21 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform, // Start preparing the process to execute, starting out with some // environment variables. let profile = target.get_profile(); - let mut p = try!(super::process(CommandType::Host(to_exec.to_c_str()), pkg, target, cx)) - .env("OUT_DIR", Some(&build_output)) - .env("CARGO_MANIFEST_DIR", Some(pkg.get_manifest_path() - .dir_path() - .display().to_string())) - .env("NUM_JOBS", Some(cx.config.jobs().to_string())) - .env("TARGET", Some(match kind { - Kind::Host => cx.config.rustc_host(), - Kind::Target => cx.target_triple(), - })) - .env("DEBUG", Some(profile.get_debug().to_string())) - .env("OPT_LEVEL", Some(profile.get_opt_level().to_string())) - .env("PROFILE", Some(profile.get_env())) - .env("HOST", Some(cx.config.rustc_host())); + let to_exec = CString::from_slice(to_exec.as_vec()); + let p = try!(super::process(CommandType::Host(to_exec), pkg, target, cx)); + let mut p = p.env("OUT_DIR", Some(&build_output)) + .env("CARGO_MANIFEST_DIR", Some(pkg.get_manifest_path() + .dir_path() + .display().to_string())) + .env("NUM_JOBS", Some(cx.config.jobs().to_string())) + .env("TARGET", Some(match kind { + Kind::Host => cx.config.rustc_host(), + Kind::Target => cx.target_triple(), + })) + .env("DEBUG", Some(profile.get_debug().to_string())) + .env("OPT_LEVEL", Some(profile.get_opt_level().to_string())) + .env("PROFILE", Some(profile.get_env())) + .env("HOST", Some(cx.config.rustc_host())); // Be sure to pass along all enabled features for this package, this is the // last piece of statically known information that we have. @@ -329,10 +329,3 @@ impl BuildOutput { Ok((library_paths, library_links)) } } - -impl fmt::Show for BuildOutput { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "BuildOutput {{ paths: [..], libs: {}, metadata: {} }}", - self.library_links, self.metadata) - } -} diff --git a/src/cargo/ops/cargo_rustc/engine.rs b/src/cargo/ops/cargo_rustc/engine.rs index ccd02401a..e81058139 100644 --- a/src/cargo/ops/cargo_rustc/engine.rs +++ b/src/cargo/ops/cargo_rustc/engine.rs @@ -1,7 +1,8 @@ use std::collections::HashMap; -use std::c_str::{CString, ToCStr}; +use std::ffi::CString; +use std::fmt::{self, Formatter}; use std::io::process::ProcessOutput; -use std::fmt::{self, Show, Formatter}; +use std::path::BytesContainer; use util::{self, CargoResult, ProcessError, ProcessBuilder}; @@ -51,13 +52,15 @@ impl CommandPrototype { &self.ty } - pub fn arg(mut self, arg: T) -> CommandPrototype { - self.args.push(arg.to_c_str()); + pub fn arg(mut self, arg: T) -> CommandPrototype { + self.args.push(CString::from_slice(arg.container_as_bytes())); self } - pub fn args(mut self, arguments: &[T]) -> CommandPrototype { - self.args.extend(arguments.iter().map(|t| t.to_c_str())); + pub fn args(mut self, arguments: &[T]) -> CommandPrototype { + self.args.extend(arguments.iter().map(|t| { + CString::from_slice(t.container_as_bytes()) + })); self } @@ -74,8 +77,10 @@ impl CommandPrototype { &self.cwd } - pub fn env(mut self, key: &str, val: Option) -> CommandPrototype { - self.env.insert(key.to_string(), val.map(|t| t.to_c_str())); + pub fn env(mut self, key: &str, + val: Option) -> CommandPrototype { + let val = val.map(|t| CString::from_slice(t.container_as_bytes())); + self.env.insert(key.to_string(), val); self } @@ -88,16 +93,15 @@ impl CommandPrototype { CommandType::Rustc => util::process("rustc"), CommandType::Rustdoc => util::process("rustdoc"), CommandType::Target(ref cmd) | CommandType::Host(ref cmd) => { - util::process(cmd.as_bytes_no_nul()) + util::process(cmd) }, }); for arg in self.args.into_iter() { - builder = builder.arg(arg.as_bytes_no_nul()); + builder = builder.arg(arg); } - for (key, val) in self.env.into_iter() { - builder = builder.env(key.as_slice(), val.as_ref().map(|v| v.as_bytes_no_nul())); + builder = builder.env(key.as_slice(), val.as_ref()); } builder = builder.cwd(self.cwd); @@ -106,19 +110,18 @@ impl CommandPrototype { } } -impl Show for CommandPrototype { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { +impl fmt::String for CommandPrototype { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.ty { CommandType::Rustc => try!(write!(f, "`rustc")), CommandType::Rustdoc => try!(write!(f, "`rustdoc")), CommandType::Target(ref cmd) | CommandType::Host(ref cmd) => { - let cmd = String::from_utf8_lossy(cmd.as_bytes_no_nul()); - try!(write!(f, "`{}", cmd)); + try!(write!(f, "`{}", String::from_utf8_lossy(cmd.as_bytes()))); }, } for arg in self.args.iter() { - try!(write!(f, " {}", String::from_utf8_lossy(arg.as_bytes_no_nul()))); + try!(write!(f, " {}", String::from_utf8_lossy(arg.as_bytes()))); } write!(f, "`") diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index bd64d2f87..d93b2540e 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -1,6 +1,5 @@ use std::collections::hash_map::Entry::{Occupied, Vacant}; -use std::hash::{Hash, Hasher}; -use std::hash::sip::SipHasher; +use std::hash::{Hash, Hasher, SipHasher}; use std::io::{self, fs, File, BufferedReader}; use std::io::fs::PathExtensions; @@ -42,7 +41,7 @@ pub type Preparation = (Freshness, Work, Work); /// from the old directories to their new locations. pub fn prepare_target(cx: &mut Context, pkg: &Package, target: &Target, kind: Kind) -> CargoResult { - let _p = profile::start(format!("fingerprint: {} / {}", + let _p = profile::start(format!("fingerprint: {} / {:?}", pkg.get_package_id(), target)); let new = dir(cx, pkg, kind); let loc = new.join(filename(target)); @@ -96,7 +95,7 @@ pub fn prepare_target(cx: &mut Context, pkg: &Package, target: &Target, } else if target.is_bin() { cx.compilation.binaries.push(dst); } else if target.is_lib() { - let pkgid = pkg.get_package_id(); + let pkgid = pkg.get_package_id().clone(); match cx.compilation.libraries.entry(pkgid) { Occupied(entry) => entry.into_mut(), Vacant(entry) => entry.insert(Vec::new()), @@ -221,9 +220,10 @@ fn is_fresh(loc: &Path, new_fingerprint: &str) -> CargoResult { /// Frob in the necessary data from the context to generate the real /// fingerprint. -fn mk_fingerprint(cx: &Context, data: &T) -> String { - let hasher = SipHasher::new_with_keys(0,0); - util::to_hex(hasher.hash(&(cx.config.rustc_version(), data))) +fn mk_fingerprint>(cx: &Context, data: &T) -> String { + let mut hasher = SipHasher::new_with_keys(0,0); + (cx.config.rustc_version(), data).hash(&mut hasher); + util::to_hex(hasher.finish()) } fn calculate_target_fresh(pkg: &Package, dep_info: &Path) -> CargoResult { diff --git a/src/cargo/ops/cargo_rustc/job.rs b/src/cargo/ops/cargo_rustc/job.rs index 2e68f496f..f3aea5f0e 100644 --- a/src/cargo/ops/cargo_rustc/job.rs +++ b/src/cargo/ops/cargo_rustc/job.rs @@ -23,7 +23,7 @@ impl R> FnBox for F { impl Work { pub fn new(f: F) -> Work where F: FnOnce(Sender) -> CargoResult<()> + Send { - Work { inner: box f } + Work { inner: Box::new(f) } } pub fn noop() -> Work { diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 3e075368b..d6f04e88b 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -24,7 +24,7 @@ pub struct JobQueue<'a, 'b> { rx: Receiver, resolve: &'a Resolve, packages: &'a PackageSet, - active: uint, + active: u32, pending: HashMap<(&'a PackageId, Stage), PendingBuild>, state: HashMap<&'a PackageId, Freshness>, ignored: HashSet<&'a PackageId>, @@ -34,7 +34,7 @@ pub struct JobQueue<'a, 'b> { /// A helper structure for metadata about the state of a building package. struct PendingBuild { /// Number of jobs currently active - amt: uint, + amt: u32, /// Current freshness state of this package. Any dirty target within a /// package will cause the entire package to become dirty. fresh: Freshness, @@ -67,7 +67,7 @@ impl<'a, 'b> JobQueue<'a, 'b> { config: &Config) -> JobQueue<'a, 'b> { let (tx, rx) = channel(); JobQueue { - pool: TaskPool::new(config.jobs()), + pool: TaskPool::new(config.jobs() as usize), queue: DependencyQueue::new(), tx: tx, rx: rx, @@ -86,7 +86,7 @@ impl<'a, 'b> JobQueue<'a, 'b> { // Record the freshness state of this package as dirty if any job is // dirty or fresh otherwise let fresh = jobs.iter().fold(Fresh, |f1, &(_, f2)| f1.combine(f2)); - match self.state.entry(&pkg.get_package_id()) { + match self.state.entry(pkg.get_package_id()) { Occupied(mut entry) => { *entry.get_mut() = entry.get().combine(fresh); } Vacant(entry) => { entry.insert(fresh); } }; @@ -116,7 +116,7 @@ impl<'a, 'b> JobQueue<'a, 'b> { loop { match self.queue.dequeue() { Some((fresh, (_, stage), (pkg, jobs))) => { - info!("start: {} {}", pkg, stage); + info!("start: {} {:?}", pkg, stage); try!(self.run(pkg, stage, fresh, jobs, config)); } None => break, @@ -127,7 +127,7 @@ impl<'a, 'b> JobQueue<'a, 'b> { // of work to finish. If any package fails to build then we stop // scheduling work as quickly as possibly. let (id, stage, fresh, result) = self.rx.recv().unwrap(); - info!(" end: {} {}", id, stage); + info!(" end: {} {:?}", id, stage); let id = *self.state.keys().find(|&k| *k == &id).unwrap(); self.active -= 1; match result { @@ -144,7 +144,7 @@ impl<'a, 'b> JobQueue<'a, 'b> { try!(config.shell().say( "Build failed, waiting for other \ jobs to finish...", YELLOW)); - for _ in self.rx.iter().take(self.active) {} + for _ in self.rx.iter().take(self.active as usize) {} } return Err(e) } @@ -164,7 +164,7 @@ impl<'a, 'b> JobQueue<'a, 'b> { fn run(&mut self, pkg: &'a Package, stage: Stage, fresh: Freshness, jobs: Vec<(Job, Freshness)>, config: &Config) -> CargoResult<()> { let njobs = jobs.len(); - let amt = if njobs == 0 {1} else {njobs}; + let amt = if njobs == 0 {1} else {njobs as u32}; let id = pkg.get_package_id().clone(); // While the jobs are all running, we maintain some metadata about how @@ -230,9 +230,9 @@ impl<'a, 'b> JobQueue<'a, 'b> { } } -impl<'a> Dependency<(&'a Resolve, &'a PackageSet)> - for (&'a PackageId, Stage) -{ +impl<'a> Dependency for (&'a PackageId, Stage) { + type Context = (&'a Resolve, &'a PackageSet); + fn dependencies(&self, &(resolve, packages): &(&'a Resolve, &'a PackageSet)) -> Vec<(&'a PackageId, Stage)> { // This implementation of `Dependency` is the driver for the structure diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index dc7649e0c..15b16b1d4 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -1,10 +1,10 @@ -use std::c_str::ToCStr; use std::collections::{HashSet, HashMap}; use std::dynamic_lib::DynamicLibrary; +use std::ffi::CString; use std::io::USER_RWX; use std::io::fs::{self, PathExtensions}; -use std::sync::Arc; use std::path; +use std::sync::Arc; use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve}; use util::{self, CargoResult, human, caused_human}; @@ -124,7 +124,8 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package, return Ok(Compilation::new(pkg)) } - debug!("compile_targets; targets={}; pkg={}; deps={}", targets, pkg, deps); + debug!("compile_targets; targets={:?}; pkg={}; deps={:?}", targets, pkg, + deps); try!(links::validate(deps)); @@ -204,7 +205,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package, compiled: bool, cx: &mut Context<'a, 'b>, jobs: &mut JobQueue<'a, 'b>) -> CargoResult<()> { - debug!("compile_pkg; pkg={}; targets={}", pkg, targets); + debug!("compile_pkg; pkg={}; targets={:?}", pkg, targets); let _p = profile::start(format!("preparing: {}", pkg)); // Packages/targets which are actually getting compiled are constructed into @@ -375,8 +376,8 @@ fn compile_custom_old(pkg: &Package, cmd: &str, // may be building a C lib for a plugin let layout = cx.layout(pkg, Kind::Target); let output = layout.native(pkg); - let mut p = try!(process(CommandType::Host(cmd.next().unwrap().to_c_str()), pkg, - target, cx)) + let exe = CString::from_slice(cmd.next().unwrap().as_bytes()); + let mut p = try!(process(CommandType::Host(exe), pkg, target, cx)) .env("OUT_DIR", Some(&output)) .env("DEPS_DIR", Some(&output)) .env("TARGET", Some(cx.target_triple())) @@ -822,14 +823,17 @@ pub fn process(cmd: CommandType, pkg: &Package, target: &Target, .env(DynamicLibrary::envvar(), Some(search_path.as_slice()))) } -fn each_dep<'a>(pkg: &Package, cx: &'a Context, f: |&'a Package|) { +fn each_dep<'a, F>(pkg: &Package, cx: &'a Context, mut f: F) + where F: FnMut(&'a Package) +{ let mut visited = HashSet::new(); let pkg = cx.get_package(pkg.get_package_id()); - visit_deps(pkg, cx, &mut visited, f); + visit_deps(pkg, cx, &mut visited, &mut f); - fn visit_deps<'a>(pkg: &'a Package, cx: &'a Context, - visited: &mut HashSet<&'a PackageId>, - f: |&'a Package|) { + fn visit_deps<'a, F>(pkg: &'a Package, cx: &'a Context, + visited: &mut HashSet<&'a PackageId>, f: &mut F) + where F: FnMut(&'a Package) + { if !visited.insert(pkg.get_package_id()) { return } f(pkg); let mut deps = match cx.resolve.deps(pkg.get_package_id()) { @@ -837,7 +841,7 @@ fn each_dep<'a>(pkg: &Package, cx: &'a Context, f: |&'a Package|) { None => return, }; for dep_id in deps { - visit_deps(cx.get_package(dep_id), cx, visited, |p| f(p)) + visit_deps(cx.get_package(dep_id), cx, visited, f); } } } diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 5a361dff6..d023c83c5 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -266,7 +266,7 @@ pub fn modify_owners(shell: &mut MultiShell, match opts.to_add { Some(ref v) => { let v = v.iter().map(|s| s.as_slice()).collect::>(); - try!(shell.status("Owner", format!("adding `{:#}` to `{}`", v, name))); + try!(shell.status("Owner", format!("adding `{:#?}` to `{}`", v, name))); try!(registry.add_owners(name.as_slice(), v.as_slice()).map_err(|e| { human(format!("failed to add owners: {}", e)) })); @@ -277,7 +277,7 @@ pub fn modify_owners(shell: &mut MultiShell, match opts.to_remove { Some(ref v) => { let v = v.iter().map(|s| s.as_slice()).collect::>(); - try!(shell.status("Owner", format!("removing `{:#}` from `{}`", + try!(shell.status("Owner", format!("removing `{:?}` from `{}`", v, name))); try!(registry.remove_owners(name.as_slice(), v.as_slice()).map_err(|e| { human(format!("failed to add owners: {}", e)) @@ -343,11 +343,11 @@ pub fn yank(shell: &mut MultiShell, } pub fn search(query: &str, shell: &mut MultiShell, index: Option) -> CargoResult<()> { - fn truncate_with_ellipsis(s: &str, max_length: uint) -> String { + fn truncate_with_ellipsis(s: &str, max_length: usize) -> String { if s.len() < max_length { s.to_string() } else { - format!("{}…", s[..max_length - 1]) + format!("{}…", &s[..max_length - 1]) } } diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 711a114ee..e649843b9 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -1,6 +1,5 @@ use std::fmt::{self, Show, Formatter}; -use std::hash::Hasher; -use std::hash::sip::SipHasher; +use std::hash::{Hash, Hasher, SipHasher}; use std::mem; use url::{self, Url}; @@ -72,7 +71,7 @@ impl<'a, 'b> GitSource<'a, 'b> { } fn ident(url: &Url) -> String { - let hasher = SipHasher::new_with_keys(0,0); + let mut hasher = SipHasher::new_with_keys(0,0); // FIXME: this really should be able to not use to_str() everywhere, but the // compiler seems to currently ask for static lifetimes spuriously. @@ -87,7 +86,8 @@ fn ident(url: &Url) -> String { ident }; - format!("{}-{}", ident, to_hex(hasher.hash(&url))) + url.hash(&mut hasher); + format!("{}-{}", ident, to_hex(hasher.finish())) } // Some hacks and heuristics for making equivalent URLs hash the same @@ -172,7 +172,7 @@ impl<'a, 'b> Source for GitSource<'a, 'b> { try!(self.config.shell().status("Updating", format!("git repository `{}`", self.remote.get_url()))); - log!(5, "updating git source `{}`", self.remote); + log!(5, "updating git source `{:?}`", self.remote); let repo = try!(self.remote.checkout(&self.db_path)); let rev = try!(repo.rev_for(&self.reference)); (repo, rev) @@ -196,8 +196,10 @@ impl<'a, 'b> Source for GitSource<'a, 'b> { } fn get(&self, ids: &[PackageId]) -> CargoResult> { - log!(5, "getting packages for package ids `{}` from `{}`", ids, self.remote); - self.path_source.as_ref().expect("BUG: update() must be called before get()").get(ids) + log!(5, "getting packages for package ids `{:?}` from `{:?}`", ids, + self.remote); + self.path_source.as_ref().expect("BUG: update() must be called \ + before get()").get(ids) } fn fingerprint(&self, _pkg: &Package) -> CargoResult { diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index da639769d..8aa38e2fc 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Show, Formatter}; +use std::fmt::{self, Formatter}; use std::io::{USER_DIR}; use std::io::fs::{mkdir_recursive, rmdir_recursive, PathExtensions}; use rustc_serialize::{Encodable, Encoder}; @@ -8,13 +8,13 @@ use git2::{self, ObjectType}; use core::GitReference; use util::{CargoResult, ChainError, human, ToUrl, internal}; -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Show)] #[allow(missing_copy_implementations)] pub struct GitRevision(git2::Oid); -impl Show for GitRevision { +impl fmt::String for GitRevision { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - self.0.fmt(f) + fmt::String::fmt(&self.0, f) } } @@ -30,8 +30,8 @@ struct EncodableGitRemote { url: String, } -impl> Encodable for GitRemote { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for GitRemote { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { EncodableGitRemote { url: self.url.to_string() }.encode(s) @@ -52,8 +52,8 @@ pub struct EncodableGitDatabase { path: String, } -impl> Encodable for GitDatabase { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for GitDatabase { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { EncodableGitDatabase { remote: self.remote.clone(), path: self.path.display().to_string() @@ -78,8 +78,8 @@ pub struct EncodableGitCheckout { revision: String, } -impl<'a, E, S: Encoder> Encodable for GitCheckout<'a> { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl<'a> Encodable for GitCheckout<'a> { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { EncodableGitCheckout { location: self.location.display().to_string(), revision: self.revision.to_string(), @@ -341,10 +341,10 @@ impl<'a> GitCheckout<'a> { } } -fn with_authentication(url: &str, - cfg: &git2::Config, - f: |&mut git2::Credentials| -> CargoResult) - -> CargoResult { +fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) + -> CargoResult + where F: FnMut(&mut git2::Credentials) -> CargoResult +{ // Prepare the authentication callbacks. // // We check the `allowed` types of credentials, and we try to do as much as @@ -397,7 +397,7 @@ pub fn fetch(repo: &git2::Repository, url: &str, with_authentication(url, &try!(repo.config()), |f| { let mut cb = git2::RemoteCallbacks::new(); - cb.credentials(|a, b, c| f.call_mut((a, b, c))); + cb.credentials(|a, b, c| f(a, b, c)); let mut remote = try!(repo.remote_anonymous(url.as_slice(), Some(refspec))); try!(remote.add_fetch("refs/tags/*:refs/tags/*")); diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index d63a07a09..c1278c18e 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -39,7 +39,7 @@ impl PathSource { } pub fn get_root_package(&self) -> CargoResult { - log!(5, "get_root_package; source={}", self); + log!(5, "get_root_package; source={:?}", self); if !self.updated { return Err(internal("source has not been updated")) @@ -121,7 +121,7 @@ impl PathSource { let mut ret = Vec::new(); 'outer: for entry in index.iter() { - let fname = entry.path.as_bytes_no_nul(); + let fname = entry.path.as_slice(); let file_path = root.join(fname); // Filter out files outside this package. @@ -230,7 +230,7 @@ impl Source for PathSource { } fn get(&self, ids: &[PackageId]) -> CargoResult> { - log!(5, "getting packages; ids={}", ids); + log!(5, "getting packages; ids={:?}", ids); Ok(self.packages.iter() .filter(|pkg| ids.iter().any(|id| pkg.get_package_id() == id)) diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index d6e0c5806..e80cc23cc 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -19,7 +19,7 @@ use self::ConfigValue as CV; pub struct Config<'a> { home_path: Path, shell: RefCell<&'a mut MultiShell>, - jobs: uint, + jobs: u32, target: Option, rustc_version: string::String, /// The current host and default target of rustc @@ -28,7 +28,7 @@ pub struct Config<'a> { impl<'a> Config<'a> { pub fn new(shell: &'a mut MultiShell, - jobs: Option, + jobs: Option, target: Option) -> CargoResult> { if jobs == Some(0) { return Err(human("jobs must be at least 1")) @@ -42,7 +42,7 @@ impl<'a> Config<'a> { This probably means that $HOME was not set.") })), shell: RefCell::new(shell), - jobs: jobs.unwrap_or(os::num_cpus()), + jobs: jobs.unwrap_or(os::num_cpus() as u32), target: target, rustc_version: rustc_version, rustc_host: rustc_host, @@ -75,7 +75,7 @@ impl<'a> Config<'a> { self.shell.borrow_mut() } - pub fn jobs(&self) -> uint { + pub fn jobs(&self) -> u32 { self.jobs } @@ -122,7 +122,7 @@ impl fmt::Show for ConfigValue { } write!(f, "]") } - CV::Table(ref table) => write!(f, "{}", table), + CV::Table(ref table) => write!(f, "{:?}", table), CV::Boolean(b, ref path) => { write!(f, "{} (from {})", b, path.display()) } @@ -130,8 +130,8 @@ impl fmt::Show for ConfigValue { } } -impl> Encodable for ConfigValue { - fn encode(&self, s: &mut S) -> Result<(), E> { +impl Encodable for ConfigValue { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { match *self { CV::String(ref string, _) => string.encode(s), CV::List(ref list) => { @@ -169,16 +169,16 @@ impl ConfigValue { fn merge(&mut self, from: ConfigValue) -> CargoResult<()> { match (self, from) { - (&CV::String(..), CV::String(..)) | - (&CV::Boolean(..), CV::Boolean(..)) => {} - (&CV::List(ref mut old), CV::List(ref mut new)) => { + (&mut CV::String(..), CV::String(..)) | + (&mut CV::Boolean(..), CV::Boolean(..)) => {} + (&mut CV::List(ref mut old), CV::List(ref mut new)) => { let new = mem::replace(new, Vec::new()); old.extend(new.into_iter()); } - (&CV::Table(ref mut old), CV::Table(ref mut new)) => { + (&mut CV::Table(ref mut old), CV::Table(ref mut new)) => { let new = mem::replace(new, HashMap::new()); for (key, value) in new.into_iter() { - match old.entry(&key) { + match old.entry(key) { Occupied(mut entry) => { try!(entry.get_mut().merge(value)); } Vacant(entry) => { entry.insert(value); } }; @@ -282,8 +282,9 @@ pub fn all_configs(pwd: Path) -> CargoResult(pwd: &Path, - walk: |File| -> CargoResult) -> CargoResult { +fn find_in_tree(pwd: &Path, mut walk: F) -> CargoResult + where F: FnMut(File) -> CargoResult +{ let mut current = pwd.clone(); loop { @@ -303,8 +304,9 @@ fn find_in_tree(pwd: &Path, Err(internal("")) } -fn walk_tree(pwd: &Path, - walk: |File| -> CargoResult<()>) -> CargoResult<()> { +fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> + where F: FnMut(File) -> CargoResult<()> +{ let mut current = pwd.clone(); loop { diff --git a/src/cargo/util/dependency_queue.rs b/src/cargo/util/dependency_queue.rs index ae7395be4..90e3a5471 100644 --- a/src/cargo/util/dependency_queue.rs +++ b/src/cargo/util/dependency_queue.rs @@ -5,7 +5,7 @@ //! it to figure out when a dependency should be built. use std::collections::hash_set::HashSet; -use std::collections::hash_map::HashMap; +use std::collections::hash_map::{HashMap, Hasher}; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::hash::Hash; @@ -47,8 +47,9 @@ pub enum Freshness { } /// A trait for discovering the dependencies of a piece of data. -pub trait Dependency: Hash + Eq + Clone { - fn dependencies(&self, cx: &C) -> Vec; +pub trait Dependency: Hash + Eq + Clone { + type Context; + fn dependencies(&self, cx: &Self::Context) -> Vec; } impl Freshness { @@ -57,7 +58,7 @@ impl Freshness { } } -impl, V> DependencyQueue { +impl DependencyQueue { /// Creates a new dependency queue with 0 packages. pub fn new() -> DependencyQueue { DependencyQueue { @@ -72,7 +73,8 @@ impl, V> DependencyQueue { /// /// It is assumed that any dependencies of this package will eventually also /// be added to the dependency queue. - pub fn enqueue(&mut self, cx: &C, fresh: Freshness, key: K, value: V) { + pub fn enqueue(&mut self, cx: &K::Context, fresh: Freshness, key: K, + value: V) { // ignore self-deps if self.dep_map.contains_key(&key) { return } @@ -83,7 +85,7 @@ impl, V> DependencyQueue { let mut my_dependencies = HashSet::new(); for dep in key.dependencies(cx).into_iter() { assert!(my_dependencies.insert(dep.clone())); - let rev = match self.reverse_dep_map.entry(&dep) { + let rev = match self.reverse_dep_map.entry(dep) { Occupied(entry) => entry.into_mut(), Vacant(entry) => entry.insert(HashSet::new()), }; @@ -110,7 +112,7 @@ impl, V> DependencyQueue { } /// Returns the number of remaining packages to be built. - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.dep_map.len() + self.pending.len() } diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 211af049a..688b30b1f 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -1,5 +1,5 @@ use std::error::{FromError, Error}; -use std::fmt::{self, Show}; +use std::fmt; use std::io::IoError; use std::io::process::{ProcessOutput, ProcessExit, ExitStatus, ExitSignal}; use std::str; @@ -21,12 +21,17 @@ pub trait CargoError: Error { fn is_human(&self) -> bool { false } } -impl Show for Box { +impl fmt::String for Box { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, "{}", self.description())); Ok(()) } } +impl fmt::Show for Box { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} impl Error for Box { fn description(&self) -> &str { (**self).description() } @@ -62,10 +67,10 @@ impl ChainError for Result { fn chain_error(self, callback: C) -> CargoResult where E2: CargoError, C: FnOnce() -> E2 { self.map_err(move |err| { - box ChainedError { + Box::new(ChainedError { error: callback(), - cause: box err, - } as Box + cause: Box::new(err), + }) as Box }) } } @@ -75,7 +80,7 @@ impl ChainError for Option { where E: CargoError, C: FnOnce() -> E { match self { Some(t) => Ok(t), - None => Err(box callback() as Box), + None => Err(Box::new(callback()) as Box), } } } @@ -108,9 +113,14 @@ impl Error for ProcessError { } } +impl fmt::String for ProcessError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(&self.desc, f) + } +} impl fmt::Show for ProcessError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.desc.fmt(f) + fmt::String::fmt(self, f) } } @@ -124,11 +134,16 @@ struct ConcreteCargoError { is_human: bool, } -impl fmt::Show for ConcreteCargoError { +impl fmt::String for ConcreteCargoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.description) } } +impl fmt::Show for ConcreteCargoError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} impl Error for ConcreteCargoError { fn description(&self) -> &str { self.description.as_slice() } @@ -168,7 +183,7 @@ pub type CliResult = Result; pub struct CliError { pub error: Box, pub unknown: bool, - pub exit_code: uint + pub exit_code: u32 } impl Error for CliError { @@ -178,17 +193,17 @@ impl Error for CliError { } impl CliError { - pub fn new(error: S, code: uint) -> CliError { + pub fn new(error: S, code: u32) -> CliError { let error = human(error.as_slice().to_string()); CliError::from_boxed(error, code) } - pub fn from_error(error: E, code: uint) -> CliError { - let error = box error as Box; + pub fn from_error(error: E, code: u32) -> CliError { + let error = Box::new(error) as Box; CliError::from_boxed(error, code) } - pub fn from_boxed(error: Box, code: uint) -> CliError { + pub fn from_boxed(error: Box, code: u32) -> CliError { let human = error.is_human(); CliError { error: error, exit_code: code, unknown: !human } } @@ -200,7 +215,7 @@ impl CliError { macro_rules! from_error { ($($p:ty,)*) => ( $(impl FromError<$p> for Box { - fn from_error(t: $p) -> Box { box t } + fn from_error(t: $p) -> Box { Box::new(t) } })* ) } @@ -218,7 +233,7 @@ from_error! { } impl FromError> for Box { - fn from_error(t: Human) -> Box { box t } + fn from_error(t: Human) -> Box { Box::new(t) } } impl CargoError for semver::ReqParseError {} @@ -271,37 +286,37 @@ pub fn process_error(msg: S, pub fn internal_error(error: S1, detail: S2) -> Box { - box ConcreteCargoError { + Box::new(ConcreteCargoError { description: error.as_slice().to_string(), detail: Some(detail.as_slice().to_string()), cause: None, is_human: false - } + }) } -pub fn internal(error: S) -> Box { - box ConcreteCargoError { +pub fn internal(error: S) -> Box { + Box::new(ConcreteCargoError { description: error.to_string(), detail: None, cause: None, is_human: false - } + }) } -pub fn human(error: S) -> Box { - box ConcreteCargoError { +pub fn human(error: S) -> Box { + Box::new(ConcreteCargoError { description: error.to_string(), detail: None, cause: None, is_human: true - } + }) } -pub fn caused_human(error: S, cause: E) -> Box { - box ConcreteCargoError { +pub fn caused_human(error: S, cause: E) -> Box { + Box::new(ConcreteCargoError { description: error.to_string(), detail: None, - cause: Some(box cause as Box), + cause: Some(Box::new(cause) as Box), is_human: true - } + }) } diff --git a/src/cargo/util/graph.rs b/src/cargo/util/graph.rs index b3214e5ff..4344c87b9 100644 --- a/src/cargo/util/graph.rs +++ b/src/cargo/util/graph.rs @@ -1,7 +1,7 @@ use std::fmt; use std::hash::Hash; use std::collections::hash_set::HashSet; -use std::collections::hash_map::{HashMap, Keys}; +use std::collections::hash_map::{HashMap, Keys, Hasher}; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::hash_set::Iter; @@ -17,7 +17,7 @@ enum Mark { pub type Nodes<'a, N> = Keys<'a, N, HashSet>; pub type Edges<'a, N> = Iter<'a, N>; -impl Graph { +impl + Clone> Graph { pub fn new() -> Graph { Graph { nodes: HashMap::new() } } @@ -27,7 +27,7 @@ impl Graph { } pub fn link(&mut self, node: N, child: N) { - match self.nodes.entry(&node) { + match self.nodes.entry(node) { Occupied(entry) => entry.into_mut(), Vacant(entry) => entry.insert(HashSet::new()), }.insert(child); @@ -72,15 +72,15 @@ impl Graph { } } -impl fmt::Show for Graph { +impl> fmt::Show for Graph { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { try!(writeln!(fmt, "Graph {{")); for (n, e) in self.nodes.iter() { - try!(writeln!(fmt, " - {}", n)); + try!(writeln!(fmt, " - {:?}", n)); for n in e.iter() { - try!(writeln!(fmt, " - {}", n)); + try!(writeln!(fmt, " - {:?}", n)); } } @@ -90,12 +90,12 @@ impl fmt::Show for Graph { } } -impl PartialEq for Graph { +impl> PartialEq for Graph { fn eq(&self, other: &Graph) -> bool { self.nodes.eq(&other.nodes) } } -impl Eq for Graph {} +impl> Eq for Graph {} -impl Clone for Graph { +impl + Clone> Clone for Graph { fn clone(&self) -> Graph { Graph { nodes: self.nodes.clone() } } diff --git a/src/cargo/util/hex.rs b/src/cargo/util/hex.rs index 005dac91e..1f557b56c 100644 --- a/src/cargo/util/hex.rs +++ b/src/cargo/util/hex.rs @@ -1,6 +1,5 @@ use std::io::MemWriter; -use std::hash::{Hasher, Hash}; -use std::hash::sip::SipHasher; +use std::hash::{Hasher, Hash, SipHasher}; use rustc_serialize::hex::ToHex; @@ -10,7 +9,8 @@ pub fn to_hex(num: u64) -> String { writer.get_ref().to_hex() } -pub fn short_hash(hashable: &H) -> String { - let hasher = SipHasher::new_with_keys(0, 0); - to_hex(hasher.hash(hashable)) +pub fn short_hash>(hashable: &H) -> String { + let mut hasher = SipHasher::new_with_keys(0, 0); + hashable.hash(&mut hasher); + to_hex(hasher.finish()) } diff --git a/src/cargo/util/lev_distance.rs b/src/cargo/util/lev_distance.rs index d37a22791..337644b3b 100644 --- a/src/cargo/util/lev_distance.rs +++ b/src/cargo/util/lev_distance.rs @@ -10,7 +10,7 @@ use std::cmp; -pub fn lev_distance(me: &str, t: &str) -> uint { +pub fn lev_distance(me: &str, t: &str) -> usize { if me.is_empty() { return t.chars().count(); } if t.is_empty() { return me.chars().count(); } @@ -48,7 +48,7 @@ fn test_lev_distance() { for c in range(0u32, MAX as u32) .filter_map(|i| from_u32(i)) .map(|i| i.to_string()) { - assert_eq!(lev_distance(c[], c[]), 0); + assert_eq!(lev_distance(&c[], &c[]), 0); } let a = "\nMäry häd ä little lämb\n\nLittle lämb\n"; diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 5f1280ccd..b89142732 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -5,7 +5,7 @@ use std::path::BytesContainer; use util::{human, CargoResult}; pub fn realpath(original: &Path) -> io::IoResult { - static MAX_LINKS_FOLLOWED: uint = 256; + const MAX_LINKS_FOLLOWED: usize = 256; let original = try!(os::make_absolute(original)); // Right now lstat on windows doesn't work quite well diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index 5f07d4f95..4f3bd6986 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -1,12 +1,13 @@ -use std::fmt::{self, Show, Formatter}; -use std::os; -use std::c_str::{CString, ToCStr}; -use std::io::process::{Command, ProcessOutput, InheritFd}; use std::collections::HashMap; +use std::ffi::CString; +use std::fmt::{self, Formatter}; +use std::io::process::{Command, ProcessOutput, InheritFd}; +use std::os; +use std::path::BytesContainer; use util::{CargoResult, ProcessError, process_error}; -#[derive(Clone,PartialEq)] +#[derive(Clone, PartialEq, Show)] pub struct ProcessBuilder { program: CString, args: Vec, @@ -14,12 +15,12 @@ pub struct ProcessBuilder { cwd: Path, } -impl Show for ProcessBuilder { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - try!(write!(f, "`{}", String::from_utf8_lossy(self.program.as_bytes_no_nul()))); +impl fmt::String for ProcessBuilder { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "`{}", String::from_utf8_lossy(self.program.as_bytes()))); for arg in self.args.iter() { - try!(write!(f, " {}", String::from_utf8_lossy(arg.as_bytes_no_nul()))); + try!(write!(f, " {}", String::from_utf8_lossy(arg.as_bytes()))); } write!(f, "`") @@ -27,13 +28,15 @@ impl Show for ProcessBuilder { } impl ProcessBuilder { - pub fn arg(mut self, arg: T) -> ProcessBuilder { - self.args.push(arg.to_c_str()); + pub fn arg(mut self, arg: T) -> ProcessBuilder { + self.args.push(CString::from_slice(arg.container_as_bytes())); self } - pub fn args(mut self, arguments: &[T]) -> ProcessBuilder { - self.args.extend(arguments.iter().map(|t| t.to_c_str())); + pub fn args(mut self, arguments: &[T]) -> ProcessBuilder { + self.args.extend(arguments.iter().map(|t| { + CString::from_slice(t.container_as_bytes()) + })); self } @@ -46,8 +49,10 @@ impl ProcessBuilder { self } - pub fn env(mut self, key: &str, val: Option) -> ProcessBuilder { - self.env.insert(key.to_string(), val.map(|t| t.to_c_str())); + pub fn env(mut self, key: &str, + val: Option) -> ProcessBuilder { + let val = val.map(|t| CString::from_slice(t.container_as_bytes())); + self.env.insert(key.to_string(), val); self } @@ -92,15 +97,15 @@ impl ProcessBuilder { } pub fn build_command(&self) -> Command { - let mut command = Command::new(self.program.as_bytes_no_nul()); + let mut command = Command::new(&self.program); command.cwd(&self.cwd); for arg in self.args.iter() { - command.arg(arg.as_bytes_no_nul()); + command.arg(arg); } for (k, v) in self.env.iter() { let k = k.as_slice(); match *v { - Some(ref v) => { command.env(k, v.as_bytes_no_nul()); } + Some(ref v) => { command.env(k, v); } None => { command.env_remove(k); } } } @@ -108,20 +113,18 @@ impl ProcessBuilder { } fn debug_string(&self) -> String { - let program = String::from_utf8_lossy(self.program.as_bytes_no_nul()); - let mut program = program.to_string(); + let mut program = format!("{}", String::from_utf8_lossy(self.program.as_bytes())); for arg in self.args.iter() { program.push(' '); - let s = String::from_utf8_lossy(arg.as_bytes_no_nul()); - program.push_str(s.as_slice()); + program.push_str(&format!("{}", String::from_utf8_lossy(arg.as_bytes()))[]); } program } } -pub fn process(cmd: T) -> CargoResult { +pub fn process(cmd: T) -> CargoResult { Ok(ProcessBuilder { - program: cmd.to_c_str(), + program: CString::from_slice(cmd.container_as_bytes()), args: Vec::new(), cwd: try!(os::getcwd()), env: HashMap::new(), diff --git a/src/cargo/util/profile.rs b/src/cargo/util/profile.rs index e0eae9dac..fbaad62fa 100644 --- a/src/cargo/util/profile.rs +++ b/src/cargo/util/profile.rs @@ -1,6 +1,6 @@ use std::os; use std::mem; -use std::fmt::Show; +use std::fmt; use time; use std::iter::repeat; use std::cell::RefCell; @@ -8,7 +8,7 @@ use std::cell::RefCell; thread_local!(static PROFILE_STACK: RefCell> = RefCell::new(Vec::new())); thread_local!(static MESSAGES: RefCell> = RefCell::new(Vec::new())); -type Message = (uint, u64, String); +type Message = (usize, u64, String); pub struct Profiler { desc: String, @@ -16,7 +16,7 @@ pub struct Profiler { fn enabled() -> bool { os::getenv("CARGO_PROFILE").is_some() } -pub fn start(desc: T) -> Profiler { +pub fn start(desc: T) -> Profiler { if !enabled() { return Profiler { desc: String::new() } } PROFILE_STACK.with(|stack| stack.borrow_mut().push(time::precise_time_ns())); @@ -35,7 +35,7 @@ impl Drop for Profiler { let stack_len = PROFILE_STACK.with(|stack| stack.borrow().len()); if stack_len == 0 { - fn print(lvl: uint, msgs: &[Message]) { + fn print(lvl: usize, msgs: &[Message]) { let mut last = 0; for (i, &(l, time, ref msg)) in msgs.iter().enumerate() { if l != lvl { continue } diff --git a/src/cargo/util/sha256.rs b/src/cargo/util/sha256.rs index 4736e3407..b9646c4a4 100644 --- a/src/cargo/util/sha256.rs +++ b/src/cargo/util/sha256.rs @@ -148,7 +148,7 @@ mod imp { CryptGetHashParam(self.hcrypthash, HP_HASHVAL, ret.as_mut_ptr(), &mut len, 0) }); - assert_eq!(len as uint, ret.len()); + assert_eq!(len as usize, ret.len()); return ret; } } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 71601bfc4..0528114b3 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -231,9 +231,9 @@ pub struct TomlProfiles { #[derive(RustcDecodable, Clone, Default)] #[allow(missing_copy_implementations)] pub struct TomlProfile { - opt_level: Option, + opt_level: Option, lto: Option, - codegen_units: Option, + codegen_units: Option, debug: Option, rpath: Option, } @@ -285,8 +285,8 @@ pub struct TomlVersion { version: semver::Version, } -impl> Decodable for TomlVersion { - fn decode(d: &mut D) -> Result { +impl Decodable for TomlVersion { + fn decode(d: &mut D) -> Result { let s = try!(d.read_str()); match s.as_slice().to_semver() { Ok(s) => Ok(TomlVersion { version: s }), @@ -557,10 +557,11 @@ impl TomlManifest { } } -fn process_dependencies<'a>(cx: &mut Context<'a>, - new_deps: Option<&HashMap>, - f: |Dependency| -> Dependency) - -> CargoResult<()> { +fn process_dependencies(cx: &mut Context, + new_deps: Option<&HashMap>, + mut f: F) -> CargoResult<()> + where F: FnMut(Dependency) -> Dependency +{ let dependencies = match new_deps { Some(ref dependencies) => dependencies, None => return Ok(()) @@ -675,9 +676,6 @@ fn normalize(libs: &[TomlLibTarget], benches: &[TomlBenchTarget], metadata: &Metadata, profiles: &TomlProfiles) -> Vec { - log!(4, "normalizing toml targets; lib={}; bin={}; example={}; test={}, benches={}", - libs, bins, examples, tests, benches); - #[derive(Copy)] enum TestDep { Needed, NotNeeded } @@ -769,9 +767,12 @@ fn normalize(libs: &[TomlLibTarget], } } - fn bin_targets(dst: &mut Vec, bins: &[TomlBinTarget], - dep: TestDep, metadata: &Metadata, profiles: &TomlProfiles, - default: |&TomlBinTarget| -> String) { + fn bin_targets(dst: &mut Vec, bins: &[TomlBinTarget], + dep: TestDep, metadata: &Metadata, + profiles: &TomlProfiles, + mut default: F) + where F: FnMut(&TomlBinTarget) -> String + { for bin in bins.iter() { let path = bin.path.clone().unwrap_or_else(|| { PathValue::String(default(bin)) @@ -811,9 +812,11 @@ fn normalize(libs: &[TomlLibTarget], } } - fn example_targets(dst: &mut Vec, examples: &[TomlExampleTarget], - profiles: &TomlProfiles, - default: |&TomlExampleTarget| -> String) { + fn example_targets(dst: &mut Vec, examples: &[TomlExampleTarget], + profiles: &TomlProfiles, + mut default: F) + where F: FnMut(&TomlExampleTarget) -> String + { for ex in examples.iter() { let path = ex.path.clone().unwrap_or_else(|| PathValue::String(default(ex))); @@ -828,9 +831,11 @@ fn normalize(libs: &[TomlLibTarget], } } - fn test_targets(dst: &mut Vec, tests: &[TomlTestTarget], - metadata: &Metadata, profiles: &TomlProfiles, - default: |&TomlTestTarget| -> String) { + fn test_targets(dst: &mut Vec, tests: &[TomlTestTarget], + metadata: &Metadata, profiles: &TomlProfiles, + mut default: F) + where F: FnMut(&TomlTestTarget) -> String + { for test in tests.iter() { let path = test.path.clone().unwrap_or_else(|| { PathValue::String(default(test)) @@ -850,9 +855,11 @@ fn normalize(libs: &[TomlLibTarget], } } - fn bench_targets(dst: &mut Vec, benches: &[TomlBenchTarget], - metadata: &Metadata, profiles: &TomlProfiles, - default: |&TomlBenchTarget| -> String) { + fn bench_targets(dst: &mut Vec, benches: &[TomlBenchTarget], + metadata: &Metadata, profiles: &TomlProfiles, + mut default: F) + where F: FnMut(&TomlBenchTarget) -> String + { for bench in benches.iter() { let path = bench.path.clone().unwrap_or_else(|| { PathValue::String(default(bench)) diff --git a/src/registry/lib.rs b/src/registry/lib.rs index f153592a8..21c8216e5 100644 --- a/src/registry/lib.rs +++ b/src/registry/lib.rs @@ -1,4 +1,4 @@ -#![feature(old_orphan_check)] +#![allow(unstable)] extern crate curl; extern crate "rustc-serialize" as rustc_serialize; @@ -76,7 +76,7 @@ pub struct NewCrateDependency { #[derive(RustcDecodable)] pub struct User { - pub id: uint, + pub id: u32, pub login: String, pub avatar: String, pub email: Option, @@ -142,9 +142,9 @@ impl Registry { MemReader::new(w.into_inner()) }; let tarball = try!(File::open(tarball).map_err(Error::Io)); - let size = stat.size as uint + header.get_ref().len(); - let mut body = ChainedReader::new(vec![box header as Box, - box tarball as Box].into_iter()); + let size = stat.size as usize + header.get_ref().len(); + let mut body = ChainedReader::new(vec![Box::new(header) as Box, + Box::new(tarball) as Box].into_iter()); let url = format!("{}/api/v1/crates/new", self.host); @@ -233,7 +233,7 @@ fn handle(response: result::Result) Ok(body) } -impl fmt::Show for Error { +impl fmt::String for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::NonUtf8Body => write!(f, "reponse body was not utf-8"), diff --git a/src/rustversion.txt b/src/rustversion.txt index 51e0fdc8d..2d05711ac 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2015-01-05 +2015-01-13 diff --git a/tests/resolve.rs b/tests/resolve.rs index d230a78a6..92d24ed6a 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -1,4 +1,4 @@ -#![feature(macro_rules)] +#![allow(unstable)] extern crate hamcrest; extern crate cargo; @@ -334,11 +334,11 @@ fn resolving_but_no_exists() { ], &mut reg); assert!(res.is_err()); - assert_eq!(res.to_string().as_slice(), "Err(\ + assert_eq!(res.unwrap_err().to_string(), "\ no package named `foo` found (required by `root`) location searched: registry http://example.com/ version required: ^1\ -)"); +"); } #[test] diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 12d3bdfee..b65a7c73d 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -1,11 +1,10 @@ -use std::c_str::ToCStr; use std::error::Error; -use std::fmt::{self, Show}; +use std::fmt; use std::io::fs::{self, PathExtensions}; use std::io::process::{ProcessOutput}; use std::io; use std::os; -use std::path::{Path,BytesContainer}; +use std::path::{Path, BytesContainer}; use std::str::{self, Str}; use url::Url; @@ -119,7 +118,7 @@ impl ProjectBuilder { self.root.join("target") } - pub fn process(&self, program: T) -> ProcessBuilder { + pub fn process(&self, program: T) -> ProcessBuilder { process(program) .unwrap() .cwd(self.root()) @@ -216,7 +215,7 @@ trait ErrMsg { fn with_err_msg(self, val: String) -> Result; } -impl ErrMsg for Result { +impl ErrMsg for Result { fn with_err_msg(self, val: String) -> Result { match self { Ok(val) => Ok(val), @@ -247,7 +246,7 @@ struct Execs { expect_stdout: Option, expect_stdin: Option, expect_stderr: Option, - expect_exit_code: Option + expect_exit_code: Option } impl Execs { @@ -262,7 +261,7 @@ impl Execs { self } - pub fn with_status(mut self, expected: int) -> Execs { + pub fn with_status(mut self, expected: i32) -> Execs { self.expect_exit_code = Some(expected); self } @@ -278,7 +277,7 @@ impl Execs { None => ham::success(), Some(code) => { ham::expect( - actual.status.matches_exit_status(code), + actual.status.matches_exit_status(code as isize), format!("exited with {}\n--- stdout\n{}\n--- stderr\n{}", actual.status, String::from_utf8_lossy(actual.output.as_slice()), @@ -384,7 +383,7 @@ fn zip_all, I2: Iterator>(a: I1, b: I2) -> ZipAl } } -impl fmt::Show for Execs { +impl fmt::String for Execs { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "execs") } @@ -426,7 +425,7 @@ struct ShellWrites { expected: String } -impl fmt::Show for ShellWrites { +impl fmt::String for ShellWrites { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "`{}` written to the shell", self.expected) } @@ -442,16 +441,16 @@ impl<'a> ham::Matcher<&'a [u8]> for ShellWrites { } } -pub fn shell_writes(string: T) -> ShellWrites { +pub fn shell_writes(string: T) -> ShellWrites { ShellWrites { expected: string.to_string() } } pub trait Tap { - fn tap(mut self, callback: |&mut Self|) -> Self; + fn tap(mut self, callback: F) -> Self; } impl Tap for T { - fn tap(mut self, callback: |&mut T|) -> T { + fn tap(mut self, callback: F) -> T { callback(&mut self); self } diff --git a/tests/support/paths.rs b/tests/support/paths.rs index 23ffa0903..837963837 100644 --- a/tests/support/paths.rs +++ b/tests/support/paths.rs @@ -1,13 +1,13 @@ use std::io::IoResult; use std::io::fs::{self, PathExtensions}; -use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering}; +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; use std::{io, os}; use cargo::util::realpath; static CARGO_INTEGRATION_TEST_DIR : &'static str = "cit"; -static NEXT_ID: AtomicUint = ATOMIC_UINT_INIT; -thread_local!(static TASK_ID: uint = NEXT_ID.fetch_add(1, Ordering::SeqCst)); +static NEXT_ID: AtomicUsize = ATOMIC_USIZE_INIT; +thread_local!(static TASK_ID: usize = NEXT_ID.fetch_add(1, Ordering::SeqCst)); pub fn root() -> Path { let path = os::self_exe_path().unwrap() diff --git a/tests/support/registry.rs b/tests/support/registry.rs index 267e0888b..dbd8164c7 100644 --- a/tests/support/registry.rs +++ b/tests/support/registry.rs @@ -115,9 +115,9 @@ pub fn pkg(name: &str, vers: &str, deps: &[(&str, &str, &str)], cksum: &str, yanked: bool) -> String { let deps = deps.iter().map(|&(a, b, c)| dep(a, b, c)).collect::>(); format!("{{\"name\":\"{}\",\"vers\":\"{}\",\ - \"deps\":{},\"cksum\":\"{}\",\"features\":{{}},\ + \"deps\":[{}],\"cksum\":\"{}\",\"features\":{{}},\ \"yanked\":{}}}", - name, vers, deps, cksum, yanked) + name, vers, deps.connect(","), cksum, yanked) } pub fn dep(name: &str, req: &str, kind: &str) -> String { diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index 593d01a18..55692edb1 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -151,6 +151,7 @@ test!(cargo_bench_failing_test { let p = project("foo") .file("Cargo.toml", basic_bin_manifest("foo").as_slice()) .file("src/foo.rs", r#" + #![allow(unstable)] extern crate test; fn hello() -> &'static str { "hello" @@ -183,7 +184,7 @@ test bench_hello ... ", .with_stderr(format!("\ thread '
' panicked at 'assertion failed: \ `(left == right) && (right == left)` (left: \ - `hello`, right: `nope`)', src{sep}foo.rs:13 + `\"hello\"`, right: `\"nope\"`)', src{sep}foo.rs:14 ", sep = path::SEP)) .with_status(101)); }); @@ -469,7 +470,7 @@ test!(cargo_bench_twice { p.cargo_process("build"); - for _ in range(0u, 2) { + for _ in range(0, 2) { assert_that(p.process(cargo_dir().join("cargo")).arg("bench"), execs().with_status(0)); } diff --git a/tests/test_cargo_build_auth.rs b/tests/test_cargo_build_auth.rs index 74b82ba45..048ad3d3d 100644 --- a/tests/test_cargo_build_auth.rs +++ b/tests/test_cargo_build_auth.rs @@ -38,7 +38,7 @@ test!(http_auth_offered { .collect() } - let t = Thread::spawn(move|| { + let t = Thread::scoped(move|| { let mut s = BufferedStream::new(a.accept().unwrap()); let req = headers(&mut s); s.write(b"\ @@ -130,7 +130,7 @@ test!(https_something_happens { let mut a = listener.listen().unwrap(); let a2 = a.clone(); let _c = Closer { a: a2 }; - let t = Thread::spawn(move|| { + let t = Thread::scoped(move|| { drop(a.accept().unwrap()); }); @@ -180,7 +180,7 @@ test!(ssh_something_happens { let mut a = listener.listen().unwrap(); let a2 = a.clone(); let _c = Closer { a: a2 }; - let t = Thread::spawn(move|| { + let t = Thread::scoped(move|| { drop(a.accept().unwrap()); }); diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 2bbf419c7..d03c40b6e 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -199,8 +199,8 @@ test!(cargo_compile_with_warnings_in_a_dep_package { name = "bar" "#) .file("bar/src/bar.rs", r#" - pub fn gimme() -> String { - "test passed".to_string() + pub fn gimme() -> &'static str { + "test passed" } fn dead() {} diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index 98b5452f0..3cdd0daf5 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -22,6 +22,7 @@ test!(custom_build_script_failed { fn main() {} "#) .file("build.rs", r#" + #![allow(unstable)] fn main() { std::os::set_exit_status(101); } diff --git a/tests/test_cargo_compile_git_deps.rs b/tests/test_cargo_compile_git_deps.rs index e29818526..12dba08bb 100644 --- a/tests/test_cargo_compile_git_deps.rs +++ b/tests/test_cargo_compile_git_deps.rs @@ -15,8 +15,8 @@ use cargo::util::{ProcessError, process}; fn setup() { } -fn git_repo(name: &str, callback: |ProjectBuilder| -> ProjectBuilder) - -> Result +fn git_repo(name: &str, callback: F) -> Result + where F: FnOnce(ProjectBuilder) -> ProjectBuilder { let mut git_project = project(name); git_project = callback(git_project); @@ -41,9 +41,10 @@ fn add(repo: &git2::Repository) { submodule.add_to_index(false).unwrap(); } let mut index = repo.index().unwrap(); - index.add_all(&["*"], git2::ADD_DEFAULT, Some(|a: &[u8], _b: &[u8]| { + index.add_all(["*"].iter(), git2::ADD_DEFAULT, + Some((&mut (|&: a: &[u8], _b: &[u8]| { if s.iter().any(|s| a.starts_with(s.path().as_vec())) {1} else {0} - })).unwrap(); + })) as &mut git2::IndexMatchedPath)).unwrap(); index.write().unwrap(); } @@ -553,7 +554,7 @@ test!(recompilation { name = "foo" "#, git_project.url())) .file("src/foo.rs", - main_file(r#""{}", bar::bar()"#, &["bar"]).as_slice()); + main_file(r#""{:?}", bar::bar()"#, &["bar"]).as_slice()); // First time around we should compile both foo and bar assert_that(p.cargo_process("build"), diff --git a/tests/test_cargo_compile_plugins.rs b/tests/test_cargo_compile_plugins.rs index 9df838c7a..7379ea16e 100644 --- a/tests/test_cargo_compile_plugins.rs +++ b/tests/test_cargo_compile_plugins.rs @@ -22,15 +22,15 @@ test!(plugin_to_the_max { path = "../bar" "#) .file("src/main.rs", r#" - #![feature(phase)] - #[phase(plugin)] extern crate bar; + #![feature(plugin)] + #[plugin] #[no_link] extern crate bar; extern crate foo_lib; fn main() { foo_lib::foo(); } "#) .file("src/foo_lib.rs", r#" - #![feature(phase)] - #[phase(plugin)] extern crate bar; + #![feature(plugin)] + #[plugin] #[no_link] extern crate bar; pub fn foo() {} "#); @@ -95,6 +95,7 @@ test!(plugin_with_dynamic_native_dependency { crate-type = ["dylib"] "#) .file("src/main.rs", r#" + #![allow(unstable)] use std::io::fs; use std::os; @@ -132,8 +133,8 @@ test!(plugin_with_dynamic_native_dependency { path = "bar" "#) .file("src/main.rs", r#" - #![feature(phase)] - #[phase(plugin)] extern crate bar; + #![feature(plugin)] + #[plugin] #[no_link] extern crate bar; fn main() {} "#) diff --git a/tests/test_cargo_cross_compile.rs b/tests/test_cargo_cross_compile.rs index e33eeb5eb..73fb1b39c 100644 --- a/tests/test_cargo_cross_compile.rs +++ b/tests/test_cargo_cross_compile.rs @@ -129,8 +129,8 @@ test!(plugin_deps { path = "../baz" "#) .file("src/main.rs", r#" - #![feature(phase)] - #[phase(plugin)] + #![feature(plugin)] + #[plugin] #[no_link] extern crate bar; extern crate baz; fn main() { @@ -207,8 +207,8 @@ test!(plugin_to_the_max { path = "../baz" "#) .file("src/main.rs", r#" - #![feature(phase)] - #[phase(plugin)] + #![feature(plugin)] + #[plugin] #[no_link] extern crate bar; extern crate baz; fn main() { @@ -329,8 +329,8 @@ test!(plugin_with_extra_dylib_dep { path = "../bar" "#) .file("src/main.rs", r#" - #![feature(phase)] - #[phase(plugin)] extern crate bar; + #![feature(plugin)] + #[plugin] #[no_link] extern crate bar; fn main() {} "#); @@ -459,25 +459,6 @@ test!(simple_cargo_run { execs().with_status(0)); }); -test!(cross_but_no_dylibs { - let p = project("foo") - .file("Cargo.toml", r#" - [package] - name = "foo" - version = "0.0.0" - authors = [] - - [lib] - name = "foo" - crate-type = ["dylib"] - "#) - .file("src/lib.rs", ""); - assert_that(p.cargo_process("build").arg("--target").arg("arm-apple-ios"), - execs().with_status(101) - .with_stderr("dylib outputs are not supported for \ - arm-apple-ios")); -}); - test!(cross_with_a_build_script { if disabled() { return } @@ -674,7 +655,7 @@ test!(build_script_only_host { fn main() { assert!(os::getenv("OUT_DIR").unwrap() .contains("target/build/d1-"), - "bad: {}", os::getenv("OUT_DIR")); + "bad: {:?}", os::getenv("OUT_DIR")); } "#); diff --git a/tests/test_cargo_package.rs b/tests/test_cargo_package.rs index 530c058d3..ccbc55a5a 100644 --- a/tests/test_cargo_package.rs +++ b/tests/test_cargo_package.rs @@ -55,7 +55,7 @@ src[..]main.rs let fname = f.filename_bytes(); assert!(fname == b"foo-0.0.1/Cargo.toml" || fname == b"foo-0.0.1/src/main.rs", - "unexpected filename: {}", f.filename()) + "unexpected filename: {:?}", f.filename()) } }); diff --git a/tests/test_cargo_publish.rs b/tests/test_cargo_publish.rs index 65d915035..ab35614b6 100644 --- a/tests/test_cargo_publish.rs +++ b/tests/test_cargo_publish.rs @@ -73,7 +73,7 @@ test!(simple { let fname = file.filename_bytes(); assert!(fname == b"foo-0.0.1/Cargo.toml" || fname == b"foo-0.0.1/src/main.rs", - "unexpected filename: {}", file.filename()) + "unexpected filename: {:?}", file.filename()) } }); diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index e41f04da6..877454357 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -137,7 +137,7 @@ failures: ---- test_hello stdout ---- thread 'test_hello' panicked at 'assertion failed: \ `(left == right) && (right == left)` (left: \ - `hello`, right: `nope`)', src{sep}foo.rs:12 + `\"hello\"`, right: `\"nope\"`)', src{sep}foo.rs:12 @@ -172,7 +172,7 @@ test!(test_with_lib_dep { /// ```rust /// extern crate foo; /// fn main() { - /// println!("{}", foo::foo()); + /// println!("{:?}", foo::foo()); /// } /// ``` /// @@ -468,7 +468,7 @@ test!(cargo_test_twice { p.cargo_process("build"); - for _ in range(0u, 2) { + for _ in range(0, 2) { assert_that(p.process(cargo_dir().join("cargo")).arg("test"), execs().with_status(0)); } diff --git a/tests/test_shell.rs b/tests/test_shell.rs index f3b07efb8..0b658a886 100644 --- a/tests/test_shell.rs +++ b/tests/test_shell.rs @@ -19,7 +19,7 @@ test!(non_tty { let config = ShellConfig { color: true, verbose: true, tty: false }; let (tx, mut rx) = pair(); - Shell::create(box tx, config).tap(|shell| { + Shell::create(Box::new(tx), config).tap(|shell| { shell.say("Hey Alex", color::RED).unwrap(); }); @@ -31,7 +31,7 @@ test!(color_explicitly_disabled { let config = ShellConfig { color: false, verbose: true, tty: true }; let (tx, mut rx) = pair(); - Shell::create(box tx, config).tap(|shell| { + Shell::create(Box::new(tx), config).tap(|shell| { shell.say("Hey Alex", color::RED).unwrap(); }); let buf = rx.read_to_end().unwrap(); @@ -45,7 +45,7 @@ test!(colored_shell { let config = ShellConfig { color: true, verbose: true, tty: true }; let (tx, mut rx) = pair(); - Shell::create(box tx, config).tap(|shell| { + Shell::create(Box::new(tx), config).tap(|shell| { shell.say("Hey Alex", color::RED).unwrap(); }); let buf = rx.read_to_end().unwrap(); diff --git a/tests/tests.rs b/tests/tests.rs index a4c1f5c79..72fde609e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,6 +1,5 @@ -#![feature(macro_rules, associated_types)] -#![feature(phase)] #![deny(warnings)] +#![allow(unstable)] extern crate cargo; extern crate flate2; @@ -11,7 +10,7 @@ extern crate tar; extern crate term; extern crate url; -#[phase(plugin, link)] +#[macro_use] extern crate log; mod support; -- 2.30.2